No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_modal.scss 4.8KB

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