_modal.scss 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. transition: transform .3s ease-out;
  28. transform: translate(0, -25%);
  29. }
  30. &.in .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. }
  42. // Actual modal
  43. .modal-content {
  44. position: relative;
  45. background-color: $modal-content-bg;
  46. background-clip: padding-box;
  47. border: $modal-content-border-width solid $modal-content-border-color;
  48. @include border-radius($border-radius-lg);
  49. @include box-shadow($modal-content-xs-box-shadow);
  50. // Remove focus outline from opened modal
  51. outline: 0;
  52. }
  53. // Modal background
  54. .modal-backdrop {
  55. position: fixed;
  56. top: 0;
  57. right: 0;
  58. bottom: 0;
  59. left: 0;
  60. z-index: $zindex-modal-bg;
  61. background-color: $modal-backdrop-bg;
  62. // Fade for backdrop
  63. &.fade { opacity: 0; }
  64. &.in { opacity: $modal-backdrop-opacity; }
  65. }
  66. // Modal header
  67. // Top section of the modal w/ title and dismiss
  68. .modal-header {
  69. padding: $modal-title-padding;
  70. border-bottom: $modal-header-border-width solid $modal-header-border-color;
  71. @include clearfix;
  72. }
  73. // Close icon
  74. .modal-header .close {
  75. margin-top: -2px;
  76. }
  77. // Title text within header
  78. .modal-title {
  79. margin: 0;
  80. line-height: $modal-title-line-height;
  81. }
  82. // Modal body
  83. // Where all modal content resides (sibling of .modal-header and .modal-footer)
  84. .modal-body {
  85. position: relative;
  86. padding: $modal-inner-padding;
  87. }
  88. // Footer (for actions)
  89. .modal-footer {
  90. padding: $modal-inner-padding;
  91. text-align: right; // right align buttons
  92. border-top: $modal-footer-border-width solid $modal-footer-border-color;
  93. @include clearfix(); // clear it in case folks use .pull-* classes on buttons
  94. }
  95. // Measure scrollbar width for padding body during modal show/hide
  96. .modal-scrollbar-measure {
  97. position: absolute;
  98. top: -9999px;
  99. width: 50px;
  100. height: 50px;
  101. overflow: scroll;
  102. }
  103. // Scale up the modal
  104. @include media-breakpoint-up(sm) {
  105. // Automatically set modal's width for larger viewports
  106. .modal-dialog {
  107. max-width: $modal-md;
  108. margin: $modal-dialog-sm-up-margin-y auto;
  109. }
  110. .modal-content {
  111. @include box-shadow($modal-content-sm-up-box-shadow);
  112. }
  113. .modal-sm { max-width: $modal-sm; }
  114. }
  115. @include media-breakpoint-up(lg) {
  116. .modal-lg { max-width: $modal-lg; }
  117. }