_modal.less 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // .modal-open - body class for killing the scroll
  2. // .modal - container to scroll within
  3. // .modal-dialog - positioning shell for the actual modal
  4. // .modal-content - actual modal w/ bg and corners and stuff
  5. .modal-open {
  6. // Kill the scroll on the body
  7. overflow: hidden;
  8. .modal {
  9. overflow-x: hidden;
  10. overflow-y: auto;
  11. }
  12. }
  13. // Container that the modal scrolls within
  14. .modal {
  15. position: fixed;
  16. top: 0;
  17. left: 0;
  18. z-index: @zindex-modal;
  19. display: none;
  20. width: 100%;
  21. height: 100%;
  22. overflow: hidden;
  23. // Prevent Chrome on Windows from adding a focus outline. For details, see
  24. // https://github.com/twbs/bootstrap/pull/10951.
  25. outline: 0;
  26. // We deliberately don't use `-webkit-overflow-scrolling: touch;` due to a
  27. // gnarly iOS Safari bug: https://bugs.webkit.org/show_bug.cgi?id=158342
  28. // See also https://github.com/twbs/bootstrap/issues/17695
  29. }
  30. // Shell div to position the modal with bottom padding
  31. .modal-dialog {
  32. position: relative;
  33. width: auto;
  34. margin: @modal-dialog-margin;
  35. // allow clicks to pass through for custom click handling to close modal
  36. pointer-events: none;
  37. // When fading in the modal, animate it to slide down
  38. .modal.fade & {
  39. #transition(@modal-transition);
  40. transform: @modal-fade-transform;
  41. }
  42. .modal.show & {
  43. transform: @modal-show-transform;
  44. }
  45. // When trying to close, animate focus to scale
  46. .modal.modal-static & {
  47. transform: @modal-scale-transform;
  48. }
  49. }
  50. .modal-dialog-scrollable {
  51. display: flex; // IE10/11
  52. max-height: subtract(100%, (@modal-dialog-margin * 2));
  53. .modal-content {
  54. max-height: subtract(100vh, (@modal-dialog-margin * 2)); // IE10/11
  55. overflow: hidden;
  56. }
  57. .modal-header,
  58. .modal-footer {
  59. flex-shrink: 0;
  60. }
  61. .modal-body {
  62. overflow-y: auto;
  63. }
  64. }
  65. .modal-dialog-centered {
  66. display: flex;
  67. align-items: center;
  68. min-height: subtract(100%, (@modal-dialog-margin * 2));
  69. // Ensure `modal-dialog-centered` extends the full height of the view (IE10/11)
  70. &::before {
  71. display: block; // IE10
  72. height: subtract(100vh, (@modal-dialog-margin * 2));
  73. height: min-content; // Reset height to 0 except on IE
  74. content: "";
  75. }
  76. // Ensure `.modal-body` shows scrollbar (IE10/11)
  77. &.modal-dialog-scrollable {
  78. flex-direction: column;
  79. justify-content: center;
  80. height: 100%;
  81. .modal-content {
  82. max-height: none;
  83. }
  84. &::before {
  85. content: none;
  86. }
  87. }
  88. }
  89. // Actual modal
  90. .modal-content {
  91. position: relative;
  92. display: flex;
  93. flex-direction: column;
  94. width: 100%; // Ensure `.modal-content` extends the full width of the parent `.modal-dialog`
  95. // counteract the pointer-events: none; in the .modal-dialog
  96. // LESS PORT: Less doesn’t strip “empty” property values so we have to check for a value first.
  97. & when not (@modal-content-color = ~"") { color: @modal-content-color; }
  98. pointer-events: auto;
  99. background-color: @modal-content-bg;
  100. background-clip: padding-box;
  101. border: @modal-content-border-width solid @modal-content-border-color;
  102. #border-radius(@modal-content-border-radius);
  103. #box-shadow(@modal-content-box-shadow-xs);
  104. // Remove focus outline from opened modal
  105. outline: 0;
  106. }
  107. // Modal background
  108. .modal-backdrop {
  109. position: fixed;
  110. top: 0;
  111. left: 0;
  112. z-index: @zindex-modal-backdrop;
  113. width: 100vw;
  114. height: 100vh;
  115. background-color: @modal-backdrop-bg;
  116. // Fade for backdrop
  117. &.fade { opacity: 0; }
  118. &.show { opacity: @modal-backdrop-opacity; }
  119. }
  120. // Modal header
  121. // Top section of the modal w/ title and dismiss
  122. .modal-header {
  123. display: flex;
  124. align-items: flex-start; // so the close btn always stays on the upper right corner
  125. justify-content: space-between; // Put modal header elements (title and dismiss) on opposite ends
  126. padding: @modal-header-padding;
  127. border-bottom: @modal-header-border-width solid @modal-header-border-color;
  128. #border-top-radius(@modal-content-inner-border-radius);
  129. .close {
  130. padding: @modal-header-padding;
  131. // auto on the left force icon to the right even when there is no .modal-title
  132. margin: (-@modal-header-padding-y) (-@modal-header-padding-x) (-@modal-header-padding-y) auto;
  133. }
  134. }
  135. // Title text within header
  136. .modal-title {
  137. margin-bottom: 0;
  138. line-height: @modal-title-line-height;
  139. }
  140. // Modal body
  141. // Where all modal content resides (sibling of .modal-header and .modal-footer)
  142. .modal-body {
  143. position: relative;
  144. // Enable `flex-grow: 1` so that the body take up as much space as possible
  145. // when there should be a fixed height on `.modal-dialog`.
  146. flex: 1 1 auto;
  147. padding: @modal-inner-padding;
  148. }
  149. // Footer (for actions)
  150. .modal-footer {
  151. display: flex;
  152. flex-wrap: wrap;
  153. align-items: center; // vertically center
  154. justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items
  155. padding: (@modal-inner-padding - @modal-footer-margin-between / 2);
  156. border-top: @modal-footer-border-width solid @modal-footer-border-color;
  157. #border-bottom-radius(@modal-content-inner-border-radius);
  158. // Place margin between footer elements
  159. // This solution is far from ideal because of the universal selector usage,
  160. // but is needed to fix https://github.com/twbs/bootstrap/issues/24800
  161. > * {
  162. margin: (@modal-footer-margin-between / 2);
  163. }
  164. }
  165. // Measure scrollbar width for padding body during modal show/hide
  166. .modal-scrollbar-measure {
  167. position: absolute;
  168. top: -9999px;
  169. width: 50px;
  170. height: 50px;
  171. overflow: scroll;
  172. }
  173. // Scale up the modal
  174. #media-breakpoint-up(sm, {
  175. // Automatically set modal's width for larger viewports
  176. .modal-dialog {
  177. max-width: @modal-md;
  178. margin: @modal-dialog-margin-y-sm-up auto;
  179. }
  180. .modal-dialog-scrollable {
  181. max-height: subtract(100%, (@modal-dialog-margin-y-sm-up * 2));
  182. .modal-content {
  183. max-height: subtract(100vh, (@modal-dialog-margin-y-sm-up * 2));
  184. }
  185. }
  186. .modal-dialog-centered {
  187. min-height: subtract(100%, (@modal-dialog-margin-y-sm-up * 2));
  188. &::before {
  189. height: subtract(100vh, (@modal-dialog-margin-y-sm-up * 2));
  190. height: min-content;
  191. }
  192. }
  193. .modal-content {
  194. #box-shadow(@modal-content-box-shadow-sm-up);
  195. }
  196. .modal-sm { max-width: @modal-sm; }
  197. });
  198. #media-breakpoint-up(lg, {
  199. .modal-lg,
  200. .modal-xl {
  201. max-width: @modal-lg;
  202. }
  203. });
  204. #media-breakpoint-up(xl, {
  205. .modal-xl { max-width: @modal-xl; }
  206. });