togglebutton.css 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * Admonition-based toggles
  3. */
  4. /* Visibility of the target */
  5. .admonition.toggle .admonition-title ~ * {
  6. transition: opacity .3s, height .3s;
  7. }
  8. /* Toggle buttons inside admonitions so we see the title */
  9. .toggle.admonition {
  10. position: relative;
  11. }
  12. /* Titles should cut off earlier to avoid overlapping w/ button */
  13. .toggle.admonition .admonition-title {
  14. padding-right: 25%;
  15. cursor: pointer;
  16. }
  17. /* hides all the content of a page until de-toggled */
  18. .toggle-hidden.admonition .admonition-title ~ * {
  19. height: 0;
  20. margin: 0;
  21. float: left; /* so they overlap when hidden */
  22. opacity: 0;
  23. visibility: hidden;
  24. }
  25. /* General button style and position*/
  26. button.toggle-button {
  27. /**
  28. * Background and shape. By default there's no background
  29. * but users can style as they wish
  30. */
  31. background: none;
  32. border: none;
  33. outline: none;
  34. /* Positioning just inside the amonition title */
  35. margin-right: 0.5em;
  36. position: absolute;
  37. right: 0em;
  38. top: .5em;
  39. float: right;
  40. padding: 0px;
  41. display: flex;
  42. }
  43. /* Display the toggle hint on wide screens */
  44. @media (min-width: 768px) {
  45. button.toggle-button.toggle-button-hidden:before {
  46. content: attr(data-toggle-hint); /* This will be filled in by JS */
  47. font-size: .8em;
  48. align-self: center;
  49. }
  50. }
  51. /* Icon behavior */
  52. .tb-icon {
  53. transition: transform .2s ease-out;
  54. height: 1.5em;
  55. width: 1.5em;
  56. stroke: currentColor; /* So that we inherit the color of other text */
  57. }
  58. details.toggle-details .tb-icon {
  59. height: 1.3em;
  60. width: 1.3em;
  61. }
  62. .toggle-button-hidden .tb-icon {
  63. transform: rotate(90deg);
  64. }
  65. /**
  66. * Details-based toggles.
  67. * In this case, we wrap elements with `.toggle` in a details block.
  68. */
  69. /* Details blocks */
  70. details.toggle-details {
  71. margin: 1em 0;
  72. }
  73. details.toggle-details summary {
  74. display: flex;
  75. align-items: center;
  76. width: fit-content;
  77. cursor: pointer;
  78. list-style: none;
  79. border-radius: .4em;
  80. border: 1px solid #ccc;
  81. background: #f8f8f8;
  82. padding: 0.4em 1em 0.4em 0.5em; /* Less padding on left because the SVG has left margin */
  83. font-size: .9em;
  84. }
  85. details.toggle-details summary:hover {
  86. background: #f6f6f6;
  87. }
  88. details.toggle-details summary:active {
  89. background: #eee;
  90. }
  91. details.toggle-details[open] summary {
  92. margin-bottom: .5em;
  93. }
  94. details.toggle-details[open] summary .tb-icon {
  95. transform: rotate(90deg);
  96. }
  97. details.toggle-details[open] summary ~ * {
  98. animation: toggle-fade-in .3s ease-out;
  99. }
  100. @keyframes toggle-fade-in {
  101. from {opacity: 0%;}
  102. to {opacity: 100%;}
  103. }
  104. /* Print rules - we hide all toggle button elements at print */
  105. @media print {
  106. /* Always hide the summary so the button doesn't show up */
  107. details.toggle-details summary {
  108. display: none;
  109. }
  110. }