_modal.scss 4.9 KB
Newer Older
1
2
3
// .modal-open      - body class for killing the scroll
// .modal           - container to scroll within
// .modal-dialog    - positioning shell for the actual modal
4
// .modal-content   - actual modal w/ bg and corners and stuff
5

6

7
.modal-open {
8
  // Kill the scroll on the body
9
  overflow: hidden;
10
11
12
13
14

  .modal {
    overflow-x: hidden;
    overflow-y: auto;
  }
15
16
17
18
}

// Container that the modal scrolls within
.modal {
19
20
21
22
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
23
  left: 0;
Mark Otto's avatar
Mark Otto committed
24
  z-index: $zindex-modal;
25
26
  display: none;
  overflow: hidden;
27
28
  // Prevent Chrome on Windows from adding a focus outline. For details, see
  // https://github.com/twbs/bootstrap/pull/10951.
Martynas's avatar
Martynas committed
29
  outline: 0;
30
31
32
  // We deliberately don't use `-webkit-overflow-scrolling: touch;` due to a
  // gnarly iOS Safari bug: https://bugs.webkit.org/show_bug.cgi?id=158342
  // See also https://github.com/twbs/bootstrap/issues/17695
33
}
34

35
36
// Shell div to position the modal with bottom padding
.modal-dialog {
37
  position: relative;
38
  width: auto;
39
  margin: $modal-dialog-margin;
40
41
  // allow clicks to pass through for custom click handling to close modal
  pointer-events: none;
42
43
44
45

  // When fading in the modal, animate it to slide down
  .modal.fade & {
    @include transition($modal-transition);
46
    transform: $modal-fade-transform;
47
48
  }
  .modal.show & {
49
    transform: $modal-show-transform;
50
  }
51
52
}

53
54
55
.modal-dialog-centered {
  display: flex;
  align-items: center;
56
  min-height: calc(100% - (#{$modal-dialog-margin} * 2));
57
58
59
60
61
62
63

  // Ensure `modal-dialog-centered` extends the full height of the view (IE10/11)
  &::before {
    display: block; // IE10
    height: calc(100vh - (#{$modal-dialog-margin} * 2));
    content: "";
  }
64
65
}

66
67
68
// Actual modal
.modal-content {
  position: relative;
69
70
  display: flex;
  flex-direction: column;
71
  width: 100%; // Ensure `.modal-content` extends the full width of the parent `.modal-dialog`
72
73
  // counteract the pointer-events: none; in the .modal-dialog
  pointer-events: auto;
Mark Otto's avatar
Mark Otto committed
74
  background-color: $modal-content-bg;
75
  background-clip: padding-box;
76
  border: $modal-content-border-width solid $modal-content-border-color;
77
  @include border-radius($modal-content-border-radius);
78
  @include box-shadow($modal-content-box-shadow-xs);
Mark Otto's avatar
Mark Otto committed
79
  // Remove focus outline from opened modal
80
  outline: 0;
81
}
82
83
84

// Modal background
.modal-backdrop {
85
  position: fixed;
86
87
  top: 0;
  right: 0;
88
  bottom: 0;
89
  left: 0;
90
  z-index: $zindex-modal-backdrop;
Mark Otto's avatar
Mark Otto committed
91
  background-color: $modal-backdrop-bg;
Mark Otto's avatar
Mark Otto committed
92

93
  // Fade for backdrop
94
  &.fade { opacity: 0; }
Starsam80's avatar
Starsam80 committed
95
  &.show { opacity: $modal-backdrop-opacity; }
96
97
98
99
}

// Modal header
// Top section of the modal w/ title and dismiss
100
.modal-header {
101
  display: flex;
102
  align-items: flex-start; // so the close btn always stays on the upper right corner
Mark Otto's avatar
linting    
Mark Otto committed
103
  justify-content: space-between; // Put modal header elements (title and dismiss) on opposite ends
104
  padding: $modal-header-padding;
105
  border-bottom: $modal-header-border-width solid $modal-header-border-color;
106
  @include border-top-radius($modal-content-border-radius);
107
108

  .close {
109
    padding: $modal-header-padding;
XhmikosR's avatar
XhmikosR committed
110
111
    // auto on the left force icon to the right even when there is no .modal-title
    margin: (-$modal-header-padding) (-$modal-header-padding) (-$modal-header-padding) auto;
112
  }
113
114
115
116
}

// Title text within header
.modal-title {
117
  margin-bottom: 0;
Mark Otto's avatar
Mark Otto committed
118
  line-height: $modal-title-line-height;
119
}
120

121
122
// Modal body
// Where all modal content resides (sibling of .modal-header and .modal-footer)
123
.modal-body {
124
  position: relative;
125
126
127
  // Enable `flex-grow: 1` so that the body take up as much space as possible
  // when should there be a fixed height on `.modal-dialog`.
  flex: 1 1 auto;
Mark Otto's avatar
Mark Otto committed
128
  padding: $modal-inner-padding;
129
}
130
131

// Footer (for actions)
132
.modal-footer {
133
134
  display: flex;
  align-items: center; // vertically center
Mark Otto's avatar
linting    
Mark Otto committed
135
  justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items
Mark Otto's avatar
Mark Otto committed
136
  padding: $modal-inner-padding;
137
  border-top: $modal-footer-border-width solid $modal-footer-border-color;
138
139
140
141

  // Easily place margin between footer elements
  > :not(:first-child) { margin-left: .25rem; }
  > :not(:last-child) { margin-right: .25rem; }
142
}
143

fat's avatar
fat committed
144
145
146
147
148
149
150
151
152
// Measure scrollbar width for padding body during modal show/hide
.modal-scrollbar-measure {
  position: absolute;
  top: -9999px;
  width: 50px;
  height: 50px;
  overflow: scroll;
}

Mark Otto's avatar
Mark Otto committed
153
// Scale up the modal
154
@include media-breakpoint-up(sm) {
155
  // Automatically set modal's width for larger viewports
156
  .modal-dialog {
Mark Otto's avatar
Mark Otto committed
157
    max-width: $modal-md;
158
    margin: $modal-dialog-margin-y-sm-up auto;
159
  }
Mark Otto's avatar
Mark Otto committed
160

161
  .modal-dialog-centered {
162
    min-height: calc(100% - (#{$modal-dialog-margin-y-sm-up} * 2));
163
164
165
166
167

    &::before {
      height: calc(100vh - (#{$modal-dialog-margin-y-sm-up} * 2));
    }

168
169
  }

Mark Otto's avatar
Mark Otto committed
170
  .modal-content {
171
    @include box-shadow($modal-content-box-shadow-sm-up);
Mark Otto's avatar
Mark Otto committed
172
  }
173

Mark Otto's avatar
Mark Otto committed
174
  .modal-sm { max-width: $modal-sm; }
175

176
}
177

Mark Otto's avatar
Mark Otto committed
178
179
@include media-breakpoint-up(lg) {
  .modal-lg { max-width: $modal-lg; }
180
}
181
182
183
184

@include media-breakpoint-up(xl) {
  .modal-xl { max-width: $modal-xl; }
}