_reboot.scss 9.94 KB
Newer Older
1
// scss-lint:disable QualifyingElement, DuplicateProperty
Mark Otto's avatar
Mark Otto committed
2

Mark Otto's avatar
Mark Otto committed
3
// Reboot
4
//
Mark Otto's avatar
Mark Otto committed
5
// Global resets to common HTML elements and more for easier usage by Bootstrap.
Mark Otto's avatar
Mark Otto committed
6
// Adds additional rules on top of Normalize.css, including several overrides.
Jacob Thornton's avatar
Jacob Thornton committed
7

8

Mark Otto's avatar
Mark Otto committed
9
// Reset the box-sizing
10
//
11
12
13
14
15
// Change from `box-sizing: content-box` to `border-box` so that when you add
// `padding` or `border`s to an element, the overall declared `width` does not
// change. For example, `width: 100px;` will always be `100px` despite the
// `border: 10px solid red;` and `padding: 20px;`.
//
Mark Otto's avatar
Mark Otto committed
16
17
// Heads up! This reset may cause conflicts with some third-party widgets. For
// recommendations on resolving such conflicts, see
18
// https://getbootstrap.com/getting-started/#third-box-sizing.
Mark Otto's avatar
Mark Otto committed
19
//
Paul Irish's avatar
Paul Irish committed
20
// Credit: https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/
21

Chris Rebert's avatar
Chris Rebert committed
22
23
24
html {
  box-sizing: border-box;
}
25

26
*,
27
28
*::before,
*::after {
Chris Rebert's avatar
Chris Rebert committed
29
  box-sizing: inherit;
Mark Otto's avatar
Mark Otto committed
30
31
32
}


33
34
// Make viewport responsive
//
Mark Otto's avatar
Mark Otto committed
35
// @viewport is needed because IE 10+ doesn't honor <meta name="viewport"> in
36
// some cases. See https://timkadlec.com/2012/10/ie10-snap-mode-and-responsive-design/.
37
// Eventually @viewport will replace <meta name="viewport">.
38
39
//
// However, `device-width` is broken on IE 10 on Windows (Phone) 8,
40
// (see https://timkadlec.com/2013/01/windows-phone-8-and-device-width/ and https://github.com/twbs/bootstrap/issues/10497)
Mark Otto's avatar
Mark Otto committed
41
42
43
// and the fix for that involves a snippet of JavaScript to sniff the user agent
// and apply some conditional CSS.
//
44
// See https://getbootstrap.com/getting-started/#support-ie10-width for the relevant hack.
45
//
Mark Otto's avatar
Mark Otto committed
46
47
// Wrap `@viewport` with `@at-root` for when folks do a nested import (e.g.,
// `.class-name { @import "bootstrap"; }`).
48
@at-root {
49
  @-ms-viewport { width: device-width; }
50
}
51

52

53
//
54
// Reset HTML, body, and more
55
//
Jacob Thornton's avatar
Jacob Thornton committed
56

57
html {
58
  // Sets a specific default `font-size` for user with `rem` type scales.
Mark Otto's avatar
Mark Otto committed
59
  font-size: $font-size-root;
60
61
62
63
64
65
  // As a side-effect of setting the @viewport above,
  // IE11 & Edge make the scrollbar overlap the content and automatically hide itself when not in use.
  // Unfortunately, the auto-showing of the scrollbar is sometimes too sensitive,
  // thus making it hard to click on stuff near the right edge of the page.
  // So we add this style to force IE11 & Edge to use a "normal", non-overlapping, non-auto-hiding scrollbar.
  // See https://github.com/twbs/bootstrap/issues/18543
66
  // and https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7165383/
67
  -ms-overflow-style: scrollbar;
68
  // Changes the default tap highlight to be completely transparent in iOS.
69
70
71
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

Jacob Thornton's avatar
Jacob Thornton committed
72
body {
73
  // Make the `body` use the `font-size-root`
Mark Otto's avatar
Mark Otto committed
74
75
  font-family: $font-family-base;
  font-size: $font-size-base;
tomhorvat's avatar
tomhorvat committed
76
  font-weight: $font-weight-base;
Mark Otto's avatar
Mark Otto committed
77
  line-height: $line-height-base;
78
  // Go easy on the eyes and use something other than `#000` for text
79
  color: $body-color;
80
  // By default, `<body>` has no `background-color` so we set one as a best practice.
Mark Otto's avatar
Mark Otto committed
81
  background-color: $body-bg;
82
83
}

Mark Otto's avatar
Mark Otto committed
84
85
86
87
88
89
90
91
92
// Suppress the focus outline on elements that cannot be accessed via keyboard.
// This prevents an unwanted focus outline from appearing around elements that
// might still respond to pointer events.
//
// Credit: https://github.com/suitcss/base
[tabindex="-1"]:focus {
  outline: none !important;
}

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

//
// Typography
//

// Remove top margins from headings
//
// By default, `<h1>`-`<h6>` all receive top and bottom margins. We nuke the top
// margin for easier control within type scales as it avoids margin collapsing.
h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: .5rem;
}

// Reset margins on paragraphs
//
// Similarly, the top margin on `<p>`s get reset. However, we also reset the
// bottom margin to use `rem` units instead of `em`.
p {
  margin-top: 0;
  margin-bottom: 1rem;
}

Mark Otto's avatar
Mark Otto committed
116
// Abbreviations
117
118
119
abbr[title],
// Add data-* attribute to help out our tooltip plugin, per https://github.com/twbs/bootstrap/issues/5257
abbr[data-original-title] {
120
121
122
123
124
125
  cursor: help;
}

address {
  margin-bottom: 1rem;
  font-style: normal;
Mark Otto's avatar
Mark Otto committed
126
  line-height: inherit;
Jacob Thornton's avatar
Jacob Thornton committed
127
128
}

129
130
131
132
133
134
ol,
ul,
dl {
  margin-top: 0;
  margin-bottom: 1rem;
}
135

136
137
138
139
140
141
142
143
ol ol,
ul ul,
ol ul,
ul ol {
  margin-bottom: 0;
}

dt {
144
  font-weight: $dt-font-weight;
145
146
147
148
}

dd {
  margin-bottom: .5rem;
149
  margin-left: 0; // Undo browser default
150
151
152
153
154
155
156
157
}

blockquote {
  margin: 0 0 1rem;
}


//
158
// Links
159
//
Jacob Thornton's avatar
Jacob Thornton committed
160
161

a {
Mark Otto's avatar
Mark Otto committed
162
  color: $link-color;
163
  text-decoration: $link-decoration;
Zlatan Vasović's avatar
Zlatan Vasović committed
164

165
  @include hover-focus {
Mark Otto's avatar
Mark Otto committed
166
167
    color: $link-hover-color;
    text-decoration: $link-hover-decoration;
Zlatan Vasović's avatar
Zlatan Vasović committed
168
169
170
  }

  &:focus {
Mark Otto's avatar
Mark Otto committed
171
    @include tab-focus();
Zlatan Vasović's avatar
Zlatan Vasović committed
172
  }
Mark Otto's avatar
Mark Otto committed
173
}
174

175
176
// And undo these styles for placeholder links/named anchors (without href)
// which have not been made explicitly keyboard-focusable (without tabindex).
177
178
179
// It would be more straightforward to just use a[href] in previous block, but that
// causes specificity issues in many other styles that are too complex to fix.
// See https://github.com/twbs/bootstrap/issues/19402
180

181
a:not([href]):not([tabindex]) {
182
183
184
185
186
187
188
189
190
191
192
193
194
  color: inherit;
  text-decoration: none;

  @include hover-focus {
    color: inherit;
    text-decoration: none;
  }

  &:focus {
    outline: none;
  }
}

195

196
197
198
199
200
201
202
203
204
//
// Code
//

pre {
  // Remove browser default top margin
  margin-top: 0;
  // Reset browser default of `1em` to use `rem`s
  margin-bottom: 1rem;
Mark Otto's avatar
Mark Otto committed
205
206
  // Normalize v4 removed this property, causing `<pre>` content to break out of wrapping code snippets
  overflow: auto;
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
}


//
// Figures
//

figure {
  // Normalize adds `margin` to `figure`s as browsers apply it inconsistently.
  // We reset that to create a better flow in-page.
  margin: 0 0 1rem;
}


//
222
// Images
223
//
224

Mark Otto's avatar
Mark Otto committed
225
img {
226
227
  // By default, `<img>`s are `inline-block`. This assumes that, and vertically
  // centers them. This won't apply should you reset them to `block` level.
Mark Otto's avatar
Mark Otto committed
228
  vertical-align: middle;
229
230
  // Note: `<img>`s are deliberately not made responsive by default.
  // For the rationale behind this, see the comments on the `.img-fluid` class.
Mark Otto's avatar
Mark Otto committed
231
232
}

233

234
235
236
237
238
239
240
241
242
243
// iOS "clickable elements" fix for role="button"
//
// Fixes "clickability" issue (and more generally, the firing of events such as focus as well)
// for traditionally non-focusable elements with role="button"
// see https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile

[role="button"] {
  cursor: pointer;
}

244
245
246
247
248
249
250

// Avoid 300ms click delay on touch devices that support the `touch-action` CSS property.
//
// In particular, unlike most other browsers, IE11+Edge on Windows 10 on touch devices and IE Mobile 10-11
// DON'T remove the click delay when `<meta name="viewport" content="width=device-width">` is present.
// However, they DO support removing the click delay via `touch-action: manipulation`.
// See:
251
// * https://v4-alpha.getbootstrap.com/content/reboot/#click-delay-optimization-for-touch
252
// * http://caniuse.com/#feat=css-touch-action
253
// * https://patrickhlauke.github.io/touch/tests/results/#suppressing-300ms-delay
254
255
256
257
258
259
260
261
262
263
264
265
266

a,
area,
button,
[role="button"],
input,
label,
select,
summary,
textarea {
  touch-action: manipulation;
}

Mark Otto's avatar
spacing    
Mark Otto committed
267

268
269
270
271
272
//
// Tables
//

table {
273
274
  // No longer part of Normalize since v4
  border-collapse: collapse;
275
276
277
278
279
280
281
282
283
  // Reset for nesting within parents with `background-color`.
  background-color: $table-bg;
}

caption {
  padding-top: $table-cell-padding;
  padding-bottom: $table-cell-padding;
  color: $text-muted;
  text-align: left;
284
  caption-side: bottom;
285
286
287
288
289
290
291
292
293
294
295
296
297
}

th {
  // Centered by default, but left-align-ed to match the `td`s below.
  text-align: left;
}


//
// Forms
//

label {
298
  // Allow labels to use `margin` for spacing.
299
  display: inline-block;
300
  margin-bottom: .5rem;
301
302
}

303
304
305
306
307
308
309
310
311
// Work around a Firefox/IE bug where the transparent `button` background
// results in a loss of the default `button` focus styles.
//
// Credit: https://github.com/suitcss/base/
button:focus {
  outline: 1px dotted;
  outline: 5px auto -webkit-focus-ring-color;
}

312
313
314
315
316
input,
button,
select,
textarea {
  // Normalize includes `font: inherit;`, so `font-family`. `font-size`, etc are
Mark Otto's avatar
Mark Otto committed
317
  // properly inherited. However, `line-height` isn't inherited there.
318
319
320
  line-height: inherit;
}

Mark Otto's avatar
Mark Otto committed
321
322
323
324
325
326
327
328
329
330
331
input[type="radio"],
input[type="checkbox"] {
  // Apply a disabled cursor for radios and checkboxes.
  //
  // Note: Neither radios nor checkboxes can be readonly.
  &:disabled {
    cursor: $cursor-disabled;
  }
}


332
333
334
335
336
337
338
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
  // Remove the default appearance of temporal inputs to avoid a Mobile Safari
  // bug where setting a custom line-height prevents text from being vertically
  // centered within the input.
339
340
  // See https://bugs.webkit.org/show_bug.cgi?id=139848
  // and https://github.com/twbs/bootstrap/issues/11266
341
342
343
  -webkit-appearance: listbox;
}

344
345
346
347
348
349
textarea {
  // Textareas should really only resize vertically so they don't break their (horizontal) containers.
  resize: vertical;
}

fieldset {
350
351
352
353
354
  // Browsers set a default `min-width: min-content;` on fieldsets,
  // unlike e.g. `<div>`s, which have `min-width: 0;` by default.
  // So we reset that to ensure fieldsets behave more like a standard block element.
  // See https://github.com/twbs/bootstrap/issues/12359
  // and https://html.spec.whatwg.org/multipage/#the-fieldset-and-legend-elements
355
  min-width: 0;
356
357
358
359
  // Reset the default outline behavior of fieldsets so they don't affect page layout.
  padding: 0;
  margin: 0;
  border: 0;
360
361
362
363
364
365
366
367
368
369
370
371
372
}

legend {
  // Reset the entire legend element to match the `fieldset`
  display: block;
  width: 100%;
  padding: 0;
  margin-bottom: .5rem;
  font-size: 1.5rem;
  line-height: inherit;
}

input[type="search"] {
373
374
375
376
377
  // This overrides the extra rounded corners on search inputs in iOS so that our
  // `.form-control` class can properly style them. Note that this cannot simply
  // be added to `.form-control` as it's not specific enough. For details, see
  // https://github.com/twbs/bootstrap/issues/11586.
  -webkit-appearance: none;
378
379
380
381
}

// todo: needed?
output {
382
  display: inline-block;
383
//  font-size: $font-size-base;
384
//  line-height: $line-height;
385
386
//  color: $input-color;
}
387
388
389
390
391

// Always hide an element with the `hidden` HTML attribute (from PureCSS).
[hidden] {
  display: none !important;
}