_modal.scss 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. // Kill the scroll on the body
  6. .modal-open {
  7. overflow: hidden;
  8. }
  9. // Container that the modal scrolls within
  10. .modal {
  11. position: fixed;
  12. top: 0;
  13. right: 0;
  14. bottom: 0;
  15. left: 0;
  16. z-index: $zindex-modal;
  17. display: none;
  18. overflow: hidden;
  19. // Prevent Chrome on Windows from adding a focus outline. For details, see
  20. // https://github.com/twbs/bootstrap/pull/10951.
  21. outline: 0;
  22. // We deliberately don't use `-webkit-overflow-scrolling: touch;` due to a
  23. // gnarly iOS Safari bug: https://bugs.webkit.org/show_bug.cgi?id=158342
  24. // See also https://github.com/twbs/bootstrap/issues/17695
  25. // When fading in the modal, animate it to slide down
  26. &.fade .modal-dialog {
  27. @include transition($modal-transition);
  28. transform: translate(0, -25%);
  29. }
  30. &.show .modal-dialog { transform: translate(0, 0); }
  31. }
  32. .modal-open .modal {
  33. overflow-x: hidden;
  34. overflow-y: auto;
  35. }
  36. // Shell div to position the modal with bottom padding
  37. .modal-dialog {
  38. position: relative;
  39. width: auto;
  40. margin: $modal-dialog-margin;
  41. // allow clicks to pass through for custom click handling to close modal
  42. pointer-events: none;
  43. }
  44. // Actual modal
  45. .modal-content {
  46. position: relative;
  47. display: flex;
  48. flex-direction: column;
  49. // counteract the pointer-events: none; in the .modal-dialog
  50. pointer-events: auto;
  51. background-color: $modal-content-bg;
  52. background-clip: padding-box;
  53. border: $modal-content-border-width solid $modal-content-border-color;
  54. @include border-radius($border-radius-lg);
  55. @include box-shadow($modal-content-box-shadow-xs);
  56. // Remove focus outline from opened modal
  57. outline: 0;
  58. }
  59. // Modal background
  60. .modal-backdrop {
  61. position: fixed;
  62. top: 0;
  63. right: 0;
  64. bottom: 0;
  65. left: 0;
  66. z-index: $zindex-modal-backdrop;
  67. background-color: $modal-backdrop-bg;
  68. // Fade for backdrop
  69. &.fade { opacity: 0; }
  70. &.show { opacity: $modal-backdrop-opacity; }
  71. }
  72. // Modal header
  73. // Top section of the modal w/ title and dismiss
  74. .modal-header {
  75. display: flex;
  76. align-items: flex-start; // so the close btn always stays on the upper right corner
  77. justify-content: space-between; // Put modal header elements (title and dismiss) on opposite ends
  78. padding: $modal-header-padding;
  79. border-bottom: $modal-header-border-width solid $modal-header-border-color;
  80. @include border-top-radius($border-radius-lg);
  81. .close {
  82. padding: $modal-header-padding;
  83. // auto on the left force icon to the right even when there is no .modal-title
  84. margin: (-$modal-header-padding) (-$modal-header-padding) (-$modal-header-padding) auto;
  85. }
  86. }
  87. // Title text within header
  88. .modal-title {
  89. margin-bottom: 0;
  90. line-height: $modal-title-line-height;
  91. }
  92. // Modal body
  93. // Where all modal content resides (sibling of .modal-header and .modal-footer)
  94. .modal-body {
  95. position: relative;
  96. // Enable `flex-grow: 1` so that the body take up as much space as possible
  97. // when should there be a fixed height on `.modal-dialog`.
  98. flex: 1 1 auto;
  99. padding: $modal-inner-padding;
  100. }
  101. // Footer (for actions)
  102. .modal-footer {
  103. display: flex;
  104. align-items: center; // vertically center
  105. justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items
  106. padding: $modal-inner-padding;
  107. border-top: $modal-footer-border-width solid $modal-footer-border-color;
  108. // Easily place margin between footer elements
  109. > :not(:first-child) { margin-left: .25rem; }
  110. > :not(:last-child) { margin-right: .25rem; }
  111. }
  112. // Measure scrollbar width for padding body during modal show/hide
  113. .modal-scrollbar-measure {
  114. position: absolute;
  115. top: -9999px;
  116. width: 50px;
  117. height: 50px;
  118. overflow: scroll;
  119. }
  120. // Scale up the modal
  121. @include media-breakpoint-up(sm) {
  122. // Automatically set modal's width for larger viewports
  123. .modal-dialog {
  124. max-width: $modal-md;
  125. margin: $modal-dialog-margin-y-sm-up auto;
  126. }
  127. .modal-content {
  128. @include box-shadow($modal-content-box-shadow-sm-up);
  129. }
  130. .modal-sm { max-width: $modal-sm; }
  131. }
  132. @include media-breakpoint-up(lg) {
  133. .modal-lg { max-width: $modal-lg; }
  134. }