UNPKG

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