_modal.scss 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. @include transition($modal-transition);
  40. transform: $modal-fade-transform;
  41. }
  42. .modal.show & {
  43. transform: $modal-show-transform;
  44. }
  45. }
  46. .modal-dialog-scrollable {
  47. display: flex; // IE10/11
  48. max-height: calc(100% - #{$modal-dialog-margin * 2});
  49. .modal-content {
  50. max-height: calc(100vh - #{$modal-dialog-margin * 2}); // IE10/11
  51. overflow: hidden;
  52. }
  53. .modal-header,
  54. .modal-footer {
  55. flex-shrink: 0;
  56. }
  57. .modal-body {
  58. overflow-y: auto;
  59. }
  60. }
  61. .modal-dialog-centered {
  62. display: flex;
  63. align-items: center;
  64. min-height: calc(100% - #{$modal-dialog-margin * 2});
  65. // Ensure `modal-dialog-centered` extends the full height of the view (IE10/11)
  66. &::before {
  67. display: block; // IE10
  68. height: calc(100vh - #{$modal-dialog-margin * 2});
  69. content: "";
  70. }
  71. // Ensure `.modal-body` shows scrollbar (IE10/11)
  72. &.modal-dialog-scrollable {
  73. flex-direction: column;
  74. justify-content: center;
  75. height: 100%;
  76. .modal-content {
  77. max-height: none;
  78. }
  79. &::before {
  80. content: none;
  81. }
  82. }
  83. }
  84. // Actual modal
  85. .modal-content {
  86. position: relative;
  87. display: flex;
  88. flex-direction: column;
  89. width: 100%; // Ensure `.modal-content` extends the full width of the parent `.modal-dialog`
  90. // counteract the pointer-events: none; in the .modal-dialog
  91. color: $modal-content-color;
  92. pointer-events: auto;
  93. background-color: $modal-content-bg;
  94. background-clip: padding-box;
  95. border: $modal-content-border-width solid $modal-content-border-color;
  96. @include border-radius($modal-content-border-radius);
  97. @include box-shadow($modal-content-box-shadow-xs);
  98. // Remove focus outline from opened modal
  99. outline: 0;
  100. }
  101. // Modal background
  102. .modal-backdrop {
  103. position: fixed;
  104. top: 0;
  105. left: 0;
  106. z-index: $zindex-modal-backdrop;
  107. width: 100vw;
  108. height: 100vh;
  109. background-color: $modal-backdrop-bg;
  110. // Fade for backdrop
  111. &.fade { opacity: 0; }
  112. &.show { opacity: $modal-backdrop-opacity; }
  113. }
  114. // Modal header
  115. // Top section of the modal w/ title and dismiss
  116. .modal-header {
  117. display: flex;
  118. align-items: flex-start; // so the close btn always stays on the upper right corner
  119. justify-content: space-between; // Put modal header elements (title and dismiss) on opposite ends
  120. padding: $modal-header-padding;
  121. border-bottom: $modal-header-border-width solid $modal-header-border-color;
  122. @include border-top-radius($modal-content-border-radius);
  123. .close {
  124. padding: $modal-header-padding;
  125. // auto on the left force icon to the right even when there is no .modal-title
  126. margin: (-$modal-header-padding-y) (-$modal-header-padding-x) (-$modal-header-padding-y) auto;
  127. }
  128. }
  129. // Title text within header
  130. .modal-title {
  131. margin-bottom: 0;
  132. line-height: $modal-title-line-height;
  133. }
  134. // Modal body
  135. // Where all modal content resides (sibling of .modal-header and .modal-footer)
  136. .modal-body {
  137. position: relative;
  138. // Enable `flex-grow: 1` so that the body take up as much space as possible
  139. // when should there be a fixed height on `.modal-dialog`.
  140. flex: 1 1 auto;
  141. padding: $modal-inner-padding;
  142. }
  143. // Footer (for actions)
  144. .modal-footer {
  145. display: flex;
  146. align-items: center; // vertically center
  147. justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items
  148. padding: $modal-inner-padding;
  149. border-top: $modal-footer-border-width solid $modal-footer-border-color;
  150. @include border-bottom-radius($modal-content-border-radius);
  151. // Easily place margin between footer elements
  152. > :not(:first-child) { margin-left: .25rem; }
  153. > :not(:last-child) { margin-right: .25rem; }
  154. }
  155. // Measure scrollbar width for padding body during modal show/hide
  156. .modal-scrollbar-measure {
  157. position: absolute;
  158. top: -9999px;
  159. width: 50px;
  160. height: 50px;
  161. overflow: scroll;
  162. }
  163. // Scale up the modal
  164. @include media-breakpoint-up(sm) {
  165. // Automatically set modal's width for larger viewports
  166. .modal-dialog {
  167. max-width: $modal-md;
  168. margin: $modal-dialog-margin-y-sm-up auto;
  169. }
  170. .modal-dialog-scrollable {
  171. max-height: calc(100% - #{$modal-dialog-margin-y-sm-up * 2});
  172. .modal-content {
  173. max-height: calc(100vh - #{$modal-dialog-margin-y-sm-up * 2});
  174. }
  175. }
  176. .modal-dialog-centered {
  177. min-height: calc(100% - #{$modal-dialog-margin-y-sm-up * 2});
  178. &::before {
  179. height: calc(100vh - #{$modal-dialog-margin-y-sm-up * 2});
  180. }
  181. }
  182. .modal-content {
  183. @include box-shadow($modal-content-box-shadow-sm-up);
  184. }
  185. .modal-sm { max-width: $modal-sm; }
  186. }
  187. @include media-breakpoint-up(lg) {
  188. .modal-lg,
  189. .modal-xl {
  190. max-width: $modal-lg;
  191. }
  192. }
  193. @include media-breakpoint-up(xl) {
  194. .modal-xl { max-width: $modal-xl; }
  195. }