UNPKG

12.3 kBSCSSView Raw
1// stylelint-disable declaration-no-important, selector-no-qualifying-type, property-no-vendor-prefix
2
3
4// Reboot
5//
6// Normalization of HTML elements, manually forked from Normalize.css to remove
7// styles targeting irrelevant browsers while applying new styles.
8//
9// Normalize is licensed MIT. https://github.com/necolas/normalize.css
10
11
12// Document
13//
14// Change from `box-sizing: content-box` so that `width` is not affected by `padding` or `border`.
15
16*,
17*::before,
18*::after {
19 box-sizing: border-box;
20}
21
22
23// Root
24//
25// Ability to the value of the root font sizes, affecting the value of `rem`.
26// null by default, thus nothing is generated.
27
28:root {
29 font-size: $font-size-root;
30
31 @if $enable-smooth-scroll {
32 @media (prefers-reduced-motion: no-preference) {
33 scroll-behavior: smooth;
34 }
35 }
36}
37
38
39// Body
40//
41// 1. Remove the margin in all browsers.
42// 2. As a best practice, apply a default `background-color`.
43// 3. Prevent adjustments of font size after orientation changes in iOS.
44// 4. Change the default tap highlight to be completely transparent in iOS.
45
46body {
47 margin: 0; // 1
48 font-family: $font-family-base;
49 @include font-size($font-size-base);
50 font-weight: $font-weight-base;
51 line-height: $line-height-base;
52 color: $body-color;
53 text-align: $body-text-align;
54 background-color: $body-bg; // 2
55 -webkit-text-size-adjust: 100%; // 3
56 -webkit-tap-highlight-color: rgba($black, 0); // 4
57}
58
59
60// Content grouping
61//
62// 1. Reset Firefox's gray color
63// 2. Set correct height and prevent the `size` attribute to make the `hr` look like an input field
64
65hr {
66 margin: $hr-margin-y 0;
67 color: $hr-color; // 1
68 background-color: currentColor;
69 border: 0;
70 opacity: $hr-opacity;
71}
72
73hr:not([size]) {
74 height: $hr-height; // 2
75}
76
77
78// Typography
79//
80// 1. Remove top margins from headings
81// By default, `<h1>`-`<h6>` all receive top and bottom margins. We nuke the top
82// margin for easier control within type scales as it avoids margin collapsing.
83
84%heading {
85 margin-top: 0; // 1
86 margin-bottom: $headings-margin-bottom;
87 font-family: $headings-font-family;
88 font-style: $headings-font-style;
89 font-weight: $headings-font-weight;
90 line-height: $headings-line-height;
91 color: $headings-color;
92}
93
94h1 {
95 @extend %heading;
96 @include font-size($h1-font-size);
97}
98
99h2 {
100 @extend %heading;
101 @include font-size($h2-font-size);
102}
103
104h3 {
105 @extend %heading;
106 @include font-size($h3-font-size);
107}
108
109h4 {
110 @extend %heading;
111 @include font-size($h4-font-size);
112}
113
114h5 {
115 @extend %heading;
116 @include font-size($h5-font-size);
117}
118
119h6 {
120 @extend %heading;
121 @include font-size($h6-font-size);
122}
123
124
125// Reset margins on paragraphs
126//
127// Similarly, the top margin on `<p>`s get reset. However, we also reset the
128// bottom margin to use `rem` units instead of `em`.
129
130p {
131 margin-top: 0;
132 margin-bottom: $paragraph-margin-bottom;
133}
134
135
136// Abbreviations
137//
138// 1. Duplicate behavior to the data-bs-* attribute for our tooltip plugin
139// 2. Add the correct text decoration in Chrome, Edge, Opera, and Safari.
140// 3. Add explicit cursor to indicate changed behavior.
141// 4. Prevent the text-decoration to be skipped.
142
143abbr[title],
144abbr[data-bs-original-title] { // 1
145 text-decoration: underline dotted; // 2
146 cursor: help; // 3
147 text-decoration-skip-ink: none; // 4
148}
149
150
151// Address
152
153address {
154 margin-bottom: 1rem;
155 font-style: normal;
156 line-height: inherit;
157}
158
159
160// Lists
161
162ol,
163ul {
164 padding-left: 2rem;
165}
166
167ol,
168ul,
169dl {
170 margin-top: 0;
171 margin-bottom: 1rem;
172}
173
174ol ol,
175ul ul,
176ol ul,
177ul ol {
178 margin-bottom: 0;
179}
180
181dt {
182 font-weight: $dt-font-weight;
183}
184
185// 1. Undo browser default
186
187dd {
188 margin-bottom: .5rem;
189 margin-left: 0; // 1
190}
191
192
193// Blockquote
194
195blockquote {
196 margin: 0 0 1rem;
197}
198
199
200// Strong
201//
202// Add the correct font weight in Chrome, Edge, and Safari
203
204b,
205strong {
206 font-weight: $font-weight-bolder;
207}
208
209
210// Small
211//
212// Add the correct font size in all browsers
213
214small {
215 @include font-size($small-font-size);
216}
217
218
219// Mark
220
221mark {
222 padding: $mark-padding;
223 background-color: $mark-bg;
224}
225
226
227// Sub and Sup
228//
229// Prevent `sub` and `sup` elements from affecting the line height in
230// all browsers.
231
232sub,
233sup {
234 position: relative;
235 @include font-size($sub-sup-font-size);
236 line-height: 0;
237 vertical-align: baseline;
238}
239
240sub { bottom: -.25em; }
241sup { top: -.5em; }
242
243
244// Links
245
246a {
247 color: $link-color;
248 text-decoration: $link-decoration;
249
250 &:hover {
251 color: $link-hover-color;
252 text-decoration: $link-hover-decoration;
253 }
254}
255
256// And undo these styles for placeholder links/named anchors (without href).
257// It would be more straightforward to just use a[href] in previous block, but that
258// causes specificity issues in many other styles that are too complex to fix.
259// See https://github.com/twbs/bootstrap/issues/19402
260
261a:not([href]):not([class]) {
262 &,
263 &:hover {
264 color: inherit;
265 text-decoration: none;
266 }
267}
268
269
270// Code
271
272pre,
273code,
274kbd,
275samp {
276 font-family: $font-family-code;
277 @include font-size(1em); // Correct the odd `em` font sizing in all browsers.
278 direction: ltr #{"/* rtl:ignore */"};
279 unicode-bidi: bidi-override;
280}
281
282// 1. Remove browser default top margin
283// 2. Reset browser default of `1em` to use `rem`s
284// 3. Don't allow content to break outside
285
286pre {
287 display: block;
288 margin-top: 0; // 1
289 margin-bottom: 1rem; // 2
290 overflow: auto; // 3
291 @include font-size($code-font-size);
292 color: $pre-color;
293
294 // Account for some code outputs that place code tags in pre tags
295 code {
296 @include font-size(inherit);
297 color: inherit;
298 word-break: normal;
299 }
300}
301
302code {
303 @include font-size($code-font-size);
304 color: $code-color;
305 word-wrap: break-word;
306
307 // Streamline the style when inside anchors to avoid broken underline and more
308 a > & {
309 color: inherit;
310 }
311}
312
313kbd {
314 padding: $kbd-padding-y $kbd-padding-x;
315 @include font-size($kbd-font-size);
316 color: $kbd-color;
317 background-color: $kbd-bg;
318 @include border-radius($border-radius-sm);
319
320 kbd {
321 padding: 0;
322 @include font-size(1em);
323 font-weight: $nested-kbd-font-weight;
324 }
325}
326
327
328// Figures
329//
330// Apply a consistent margin strategy (matches our type styles).
331
332figure {
333 margin: 0 0 1rem;
334}
335
336
337// Images and content
338
339img,
340svg {
341 vertical-align: middle;
342}
343
344
345// Tables
346//
347// Prevent double borders
348
349table {
350 caption-side: bottom;
351 border-collapse: collapse;
352}
353
354caption {
355 padding-top: $table-cell-padding-y;
356 padding-bottom: $table-cell-padding-y;
357 color: $table-caption-color;
358 text-align: left;
359}
360
361// 1. Removes font-weight bold by inheriting
362// 2. Matches default `<td>` alignment by inheriting `text-align`.
363// 3. Fix alignment for Safari
364
365th {
366 font-weight: $table-th-font-weight; // 1
367 text-align: inherit; // 2
368 text-align: -webkit-match-parent; // 3
369}
370
371thead,
372tbody,
373tfoot,
374tr,
375td,
376th {
377 border-color: inherit;
378 border-style: solid;
379 border-width: 0;
380}
381
382
383// Forms
384//
385// 1. Allow labels to use `margin` for spacing.
386
387label {
388 display: inline-block; // 1
389}
390
391// Remove the default `border-radius` that macOS Chrome adds.
392// See https://github.com/twbs/bootstrap/issues/24093
393
394button {
395 // stylelint-disable-next-line property-disallowed-list
396 border-radius: 0;
397}
398
399// Explicitly remove focus outline in Chromium when it shouldn't be
400// visible (e.g. as result of mouse click or touch tap). It already
401// should be doing this automatically, but seems to currently be
402// confused and applies its very visible two-tone outline anyway.
403
404button:focus:not(:focus-visible) {
405 outline: 0;
406}
407
408// 1. Remove the margin in Firefox and Safari
409
410input,
411button,
412select,
413optgroup,
414textarea {
415 margin: 0; // 1
416 font-family: inherit;
417 @include font-size(inherit);
418 line-height: inherit;
419}
420
421// Remove the inheritance of text transform in Firefox
422button,
423select {
424 text-transform: none;
425}
426// Set the cursor for non-`<button>` buttons
427//
428// Details at https://github.com/twbs/bootstrap/pull/30562
429[role="button"] {
430 cursor: pointer;
431}
432
433select {
434 // Remove the inheritance of word-wrap in Safari.
435 // See https://github.com/twbs/bootstrap/issues/24990
436 word-wrap: normal;
437
438 // Undo the opacity change from Chrome
439 &:disabled {
440 opacity: 1;
441 }
442}
443
444// Remove the dropdown arrow in Chrome from inputs built with datalists.
445// See https://stackoverflow.com/a/54997118
446
447[list]::-webkit-calendar-picker-indicator {
448 display: none;
449}
450
451// 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
452// controls in Android 4.
453// 2. Correct the inability to style clickable types in iOS and Safari.
454// 3. Opinionated: add "hand" cursor to non-disabled button elements.
455
456button,
457[type="button"], // 1
458[type="reset"],
459[type="submit"] {
460 -webkit-appearance: button; // 2
461
462 @if $enable-button-pointers {
463 &:not(:disabled) {
464 cursor: pointer; // 3
465 }
466 }
467}
468
469// Remove inner border and padding from Firefox, but don't restore the outline like Normalize.
470
471::-moz-focus-inner {
472 padding: 0;
473 border-style: none;
474}
475
476// 1. Textareas should really only resize vertically so they don't break their (horizontal) containers.
477
478textarea {
479 resize: vertical; // 1
480}
481
482// 1. Browsers set a default `min-width: min-content;` on fieldsets,
483// unlike e.g. `<div>`s, which have `min-width: 0;` by default.
484// So we reset that to ensure fieldsets behave more like a standard block element.
485// See https://github.com/twbs/bootstrap/issues/12359
486// and https://html.spec.whatwg.org/multipage/#the-fieldset-and-legend-elements
487// 2. Reset the default outline behavior of fieldsets so they don't affect page layout.
488
489fieldset {
490 min-width: 0; // 1
491 padding: 0; // 2
492 margin: 0; // 2
493 border: 0; // 2
494}
495
496// 1. By using `float: left`, the legend will behave like a block element.
497// This way the border of a fieldset wraps around the legend if present.
498// 2. Fix wrapping bug.
499// See https://github.com/twbs/bootstrap/issues/29712
500
501legend {
502 float: left; // 1
503 width: 100%;
504 padding: 0;
505 margin-bottom: $legend-margin-bottom;
506 @include font-size($legend-font-size);
507 font-weight: $legend-font-weight;
508 line-height: inherit;
509
510 + * {
511 clear: left; // 2
512 }
513}
514
515// Fix height of inputs with a type of datetime-local, date, month, week, or time
516// See https://github.com/twbs/bootstrap/issues/18842
517
518::-webkit-datetime-edit-fields-wrapper,
519::-webkit-datetime-edit-text,
520::-webkit-datetime-edit-minute,
521::-webkit-datetime-edit-hour-field,
522::-webkit-datetime-edit-day-field,
523::-webkit-datetime-edit-month-field,
524::-webkit-datetime-edit-year-field {
525 padding: 0;
526}
527
528::-webkit-inner-spin-button {
529 height: auto;
530}
531
532// 1. Correct the outline style in Safari.
533// 2. This overrides the extra rounded corners on search inputs in iOS so that our
534// `.form-control` class can properly style them. Note that this cannot simply
535// be added to `.form-control` as it's not specific enough. For details, see
536// https://github.com/twbs/bootstrap/issues/11586.
537
538[type="search"] {
539 outline-offset: -2px; // 1
540 -webkit-appearance: textfield; // 2
541}
542
543// 1. A few input types should stay LTR
544// See https://rtlstyling.com/posts/rtl-styling#form-inputs
545// 2. RTL only output
546// See https://rtlcss.com/learn/usage-guide/control-directives/#raw
547
548/* rtl:raw:
549[type="tel"],
550[type="url"],
551[type="email"],
552[type="number"] {
553 direction: ltr;
554}
555*/
556
557// Remove the inner padding in Chrome and Safari on macOS.
558
559::-webkit-search-decoration {
560 -webkit-appearance: none;
561}
562
563// Remove padding around color pickers in webkit browsers
564
565::-webkit-color-swatch-wrapper {
566 padding: 0;
567}
568
569
570// Inherit font family and line height for file input buttons
571
572::file-selector-button {
573 font: inherit;
574}
575
576// 1. Change font properties to `inherit`
577// 2. Correct the inability to style clickable types in iOS and Safari.
578
579::-webkit-file-upload-button {
580 font: inherit; // 1
581 -webkit-appearance: button; // 2
582}
583
584// Correct element displays
585
586output {
587 display: inline-block;
588}
589
590// Remove border from iframe
591
592iframe {
593 border: 0;
594}
595
596// Summary
597//
598// 1. Add the correct display in all browsers
599
600summary {
601 display: list-item; // 1
602 cursor: pointer;
603}
604
605
606// Progress
607//
608// Add the correct vertical alignment in Chrome, Firefox, and Opera.
609
610progress {
611 vertical-align: baseline;
612}
613
614
615// Hidden attribute
616//
617// Always hide an element with the `hidden` HTML attribute.
618
619[hidden] {
620 display: none !important;
621}