Last active
June 27, 2020 17:40
-
-
Save TCotton/4e0b43bdc1dd716272f30527846dc708 to your computer and use it in GitHub Desktop.
CSS reset / starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*:focus:not(:focus-visible), | |
*::before:focus:not(:focus-visible), | |
*::after:focus:not(:focus-visible) { | |
outline: none; | |
} | |
/* https://medium.com/@matuzo/writing-css-with-accessibility-in-mind-8514a0007939 */ | |
.visually-hidden { | |
position: absolute; | |
white-space: nowrap; | |
width: 1px; | |
height: 1px; | |
overflow: hidden; | |
border: 0; | |
padding: 0; | |
clip: rect(0 0 0 0); | |
clip-path: inset(50%); | |
margin: -1px; | |
} | |
/* https://www.scottohara.me/blog/2019/01/12/lists-and-safari.html */ | |
.plain-list { | |
list-style: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E"); | |
padding-left: 0; | |
} | |
/* prettier-ignore */ | |
@media(prefers-reduced-motion: reduce) { | |
*, | |
*::before, | |
*::after { | |
transition: none !important; | |
animation: none !important; | |
scroll-behavior: auto !important; | |
} | |
} | |
:root { | |
--link-colour: #0000FF; | |
--selection-colour: #000000; | |
--selection-bg-colour: #b3d4fc; | |
--focus-border: #cccccc; | |
} | |
html, | |
body, | |
div, | |
span, | |
applet, | |
object, | |
iframe, | |
h1, | |
h2, | |
h3, | |
h4, | |
h5, | |
h6, | |
p, | |
blockquote, | |
pre, | |
a, | |
abbr, | |
acronym, | |
address, | |
big, | |
cite, | |
code, | |
del, | |
dfn, | |
em, | |
img, | |
ins, | |
kbd, | |
q, | |
s, | |
samp, | |
small, | |
strike, | |
strong, | |
sub, | |
sup, | |
tt, | |
var, | |
b, | |
u, | |
i, | |
center, | |
dl, | |
dt, | |
dd, | |
ol, | |
ul, | |
li, | |
fieldset, | |
form, | |
label, | |
legend, | |
table, | |
caption, | |
tbody, | |
tfoot, | |
thead, | |
tr, | |
th, | |
td, | |
article, | |
aside, | |
canvas, | |
details, | |
figcaption, | |
figure, | |
footer, | |
header, | |
hgroup, | |
menu, | |
nav, | |
section, | |
summary, | |
time, | |
mark, | |
audio, | |
video, | |
context, | |
toolbar, | |
picture, | |
source { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
vertical-align: baseline; | |
font-size: 100%; | |
background: transparent; | |
} | |
/* ========================================================================== | |
HTML5 display definitions | |
========================================================================== */ | |
/** | |
* Correct `block` display not defined for any HTML5 element in IE 8/9. | |
* Correct `block` display not defined for `details` or `summary` in IE 10/11 | |
* and Firefox. | |
* Correct `block` display not defined for `main` in IE 11. | |
*/ | |
article, | |
aside, | |
details, | |
figcaption, | |
figure, | |
footer, | |
header, | |
main, | |
menu, | |
nav, | |
section, | |
summary { | |
display: block; | |
} | |
/** | |
* 1. Correct `inline-block` display not defined in IE 8/9. | |
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. | |
*/ | |
audio, | |
canvas, | |
progress, | |
video { | |
/* 1 */ | |
display: inline-block; | |
/* 2 */ | |
vertical-align: baseline; | |
} | |
/** | |
* Prevent modern browsers from displaying `audio` without controls. | |
* Remove excess height in iOS 5 devices. | |
*/ | |
audio:not([controls]) { | |
display: none; | |
height: 0; | |
} | |
/** | |
* Address `[hidden]` styling not present in IE 8/9. | |
* Hide the `template` element in IE, Safari, and Firefox < 22. | |
*/ | |
[hidden], | |
template { | |
display: none; | |
} | |
/** | |
* 1. Correct the inability to style clickable types in iOS and Safari. | |
* 2. Change font properties to `inherit` in Safari. | |
*/ | |
::-webkit-file-upload-button { | |
/* 1 */ | |
-webkit-appearance: button; | |
/* 2 */ | |
font: inherit; | |
} | |
/* ========================================================================== | |
Base | |
========================================================================== */ | |
/** | |
* 1. Set default font family to sans-serif. | |
* 2. Prevent iOS text size adjust after orientation change, without disabling | |
* user zoom. | |
* 3. Correct the line height in all browsers. | |
*/ | |
html { | |
font-family: sans-serif; | |
text-size-adjust: 100%; | |
line-height: 1.15; | |
} | |
/** | |
* Remove default margin. | |
*/ | |
body { | |
margin: 0; | |
} | |
/* ========================================================================== | |
Links | |
========================================================================== */ | |
/** | |
* 1. Remove the gray background on active links in IE 10. | |
* 2. Remove the gaps in underlines in iOS 8+ and Safari 8+. | |
*/ | |
a { | |
background-color: transparent; | |
/* 1 */ | |
-webkit-text-decoration-skip: objects; | |
/* 2 */ | |
} | |
/** | |
* Address `outline` inconsistency between Chrome and other browsers. | |
*/ | |
a:focus { | |
outline: thin dotted var(--focus-border); | |
} | |
textarea:focus, | |
input:focus { | |
outline: thin dotted var(--focus-border); | |
} | |
:focus { | |
outline: thin dotted var(--focus-border); | |
} | |
/** | |
* 1. Remove the bottom border in Chrome 57- | |
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. | |
*/ | |
abbr[title] { | |
border-bottom: none; | |
/* 1 */ | |
text-decoration: underline; | |
/* 2 */ | |
text-decoration: underline dotted; | |
/* 2 */ | |
} | |
/** | |
* Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. | |
*/ | |
b, | |
strong { | |
font-weight: bolder; | |
} | |
/** | |
* Address styling not present in Safari 5 and Chrome. | |
*/ | |
dfn { | |
font-style: italic; | |
} | |
/** | |
* Address differences between Firefox and other browsers. | |
*/ | |
/** | |
* 1. Add the correct box sizing in Firefox. | |
* 2. Show the overflow in Edge and IE. | |
*/ | |
hr { | |
/* 1 */ | |
box-sizing: content-box; | |
/* 1 */ | |
height: 0; | |
/* 2 */ | |
overflow: visible; | |
} | |
/** | |
* Address styling not present in IE 8/9. | |
*/ | |
mark { | |
background: #ff0; | |
color: #000; | |
} | |
/** | |
* Correct font family set oddly in Safari 5 and Chrome. | |
*/ | |
code, | |
kbd, | |
pre, | |
samp { | |
font-family: monospace, monospace; | |
font-size: 1em; | |
} | |
/** | |
* Improve readability of pre-formatted text in all browsers. | |
*/ | |
pre { | |
white-space: pre-wrap; | |
} | |
/** | |
* Set consistent quote types. | |
*/ | |
q { | |
quotes: "\201C""\201D""\2018""\2019"; | |
} | |
/** | |
* Address inconsistent and variable font size in all browsers. | |
*/ | |
small { | |
font-size: 80%; | |
} | |
/** | |
* Prevent `sub` and `sup` affecting `line-height` in all browsers. | |
*/ | |
sub, | |
sup { | |
font-size: 75%; | |
line-height: 0; | |
position: relative; | |
vertical-align: baseline; | |
} | |
sup { | |
top: -0.5em; | |
} | |
sub { | |
bottom: -0.25em; | |
} | |
/* ========================================================================== | |
Embedded content | |
========================================================================== */ | |
/** | |
* Remove border when inside `a` element in IE 8/9. | |
*/ | |
img { | |
border: 0; | |
} | |
/** | |
* Change the fill color to match the text color in all browsers (opinionated). | |
*/ | |
svg { | |
fill: currentColor; | |
} | |
/** | |
* Correct overflow displayed oddly in IE 9. | |
*/ | |
svg:not(:root) { | |
overflow: hidden; | |
} | |
/* ========================================================================== | |
Figures | |
========================================================================== */ | |
/** | |
* Address margin not present in IE 8/9 and Safari 5. | |
*/ | |
figure { | |
margin: 0; | |
} | |
/* ========================================================================== | |
Forms | |
========================================================================== */ | |
/** | |
* Define consistent border, margin, and padding. | |
*/ | |
fieldset { | |
border: none; | |
margin: 0; | |
padding: 0; | |
} | |
/** | |
* 1. Correct the text wrapping in Edge and IE. | |
* 2. Correct the color inheritance from `fieldset` elements in IE. | |
* 3. Remove the padding so developers are not caught out when they zero out | |
* `fieldset` elements in all browsers. | |
*/ | |
legend { | |
/* 1 */ | |
box-sizing: border-box; | |
/* 2 */ | |
color: inherit; | |
/* 1 */ | |
display: table; | |
/* 1 */ | |
max-width: 100%; | |
/* 3 */ | |
padding: 0; | |
/* 1 */ | |
white-space: normal; | |
} | |
/** | |
* 1. Change the font styles in all browsers. | |
* 2. Remove the margin in Firefox and Safari. | |
*/ | |
button, | |
input, | |
optgroup, | |
select, | |
textarea { | |
font-family: inherit; | |
/* 1 */ | |
font-size: 100%; | |
/* 1 */ | |
line-height: 1.15; | |
/* 1 */ | |
margin: 0; | |
/* 2 */ | |
} | |
/** | |
* Address inconsistent `text-transform` inheritance for `button` and `select`. | |
* All other form control elements do not inherit `text-transform` values. | |
* Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+. | |
* Correct `select` style inheritance in Firefox 4+ and Opera. | |
*/ | |
button, | |
select { | |
text-transform: none; | |
} | |
/** | |
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` | |
* and `video` controls. | |
* 2. Correct inability to style clickable `input` types in iOS. | |
* 3. Improve usability and consistency of cursor style between image-type | |
* `input` and others. | |
*/ | |
button, | |
html input[type="button"], | |
input[type="reset"], | |
input[type="submit"] { | |
/* 2 */ | |
-webkit-appearance: button; | |
/* 3 */ | |
cursor: pointer; | |
} | |
/** | |
* Re-set default cursor for disabled elements. | |
*/ | |
button[disabled], | |
html input[disabled] { | |
cursor: default; | |
} | |
/** | |
* 1. Correct the odd appearance in Chrome and Safari. | |
* 2. Correct the outline style in Safari. | |
*/ | |
[type="search"] { | |
appearance: textfield; | |
/* 1 */ | |
outline-offset: -2px; | |
/* 2 */ | |
} | |
/** | |
* Remove inner padding and search cancel button in Safari 5 and Chrome | |
* on OS X. | |
*/ | |
input[type="search"]::-webkit-search-cancel-button, | |
input[type="search"]::-webkit-search-decoration { | |
-webkit-appearance: none; | |
} | |
/** | |
* Remove the inner border and padding in Firefox. | |
*/ | |
button::-moz-focus-inner, | |
[type="button"]::-moz-focus-inner, | |
[type="reset"]::-moz-focus-inner, | |
[type="submit"]::-moz-focus-inner { | |
border-style: none; | |
padding: 0; | |
} | |
/** | |
* Restore the focus styles unset by the previous rule. | |
*/ | |
button:-moz-focusring, | |
[type="button"]:-moz-focusring, | |
[type="reset"]:-moz-focusring, | |
[type="submit"]:-moz-focusring { | |
outline: 1px dotted ButtonText; | |
} | |
/** | |
* Address Firefox 4+ setting `line-height` on `input` using `!important` in | |
* the UA stylesheet. | |
*/ | |
input { | |
line-height: normal; | |
} | |
/** | |
* 1. Remove default vertical scrollbar in IE 8/9. | |
* 2. Improve readability and alignment in all browsers. | |
*/ | |
textarea { | |
/* 1 */ | |
overflow: auto; | |
/* 2 */ | |
vertical-align: top; | |
} | |
/* ========================================================================== | |
Tables | |
========================================================================== */ | |
/** | |
* Remove most spacing between table cells. | |
*/ | |
table { | |
border-collapse: collapse; | |
border-spacing: 0; | |
} | |
td, | |
th { | |
padding: 0; | |
} | |
/* Interactive | |
========================================================================== */ | |
/* | |
* Add the correct display in IE 9-. | |
* 1. Add the correct display in Edge, IE, and Firefox. | |
*/ | |
details, | |
menu { | |
display: block; | |
} | |
/* | |
* Add the correct display in all browsers. | |
*/ | |
summary { | |
display: list-item; | |
} | |
/* Scripting | |
========================================================================== */ | |
/** | |
* Add the correct display in IE 9-. | |
*/ | |
canvas { | |
display: inline-block; | |
} | |
/** | |
* Add the correct display in IE. | |
*/ | |
template { | |
display: none; | |
} | |
/* Hidden | |
========================================================================== */ | |
/** | |
* Add the correct display in IE 10-. | |
*/ | |
[hidden] { | |
display: none; | |
} | |
/* WAI-ARIA (https://www.w3.org/TR/html5/dom.html#wai-aria) | |
========================================================================== */ | |
/** | |
* Change the cursor on busy elements (opinionated). | |
*/ | |
[aria-busy="true"] { | |
cursor: progress; | |
} | |
/* | |
* Change the cursor on control elements (opinionated). | |
*/ | |
[aria-controls] { | |
cursor: pointer; | |
} | |
/* | |
* Change the cursor on disabled, not-editable, or otherwise | |
* inoperable elements (opinionated). | |
*/ | |
[aria-disabled] { | |
cursor: default; | |
} | |
/* User interaction (https://www.w3.org/TR/html5/editing.html) | |
========================================================================== */ | |
/* | |
* Remove the tapping delay on clickable elements (opinionated). | |
* 1. Remove the tapping delay | |
*/ | |
a, | |
area, | |
button, | |
input, | |
label, | |
select, | |
textarea, | |
[tabindex] { | |
/* 1 */ | |
touch-action: manipulation; | |
} | |
/* | |
* Change the display on visually hidden accessible elements (opinionated). | |
*/ | |
[hidden][aria-hidden="false"] { | |
clip: rect(0, 0, 0, 0); | |
display: inherit; | |
position: absolute; | |
} | |
[hidden][aria-hidden="false"]:focus { | |
clip: auto; | |
} | |
/* disable / enable fort kerning and in all modern browers from ie9 upwards */ | |
body { | |
/* only optimize text for headers due to performance issues */ | |
text-rendering: optimizeSpeed; | |
-moz-osx-font-smoothing: subpixel-antialiased; | |
-webkit-font-smoothing: subpixel-antialiased; | |
font-kerning: auto; | |
} | |
h1, | |
h2, | |
h3, | |
h4, | |
h5, | |
h6, | |
th, | |
td, | |
caption { | |
font-weight: normal; | |
/* just left it in the headers. Was making font less legible elsewhere */ | |
text-rendering: optimizeLegibility; | |
font-kerning: normal; | |
font-feature-settings: "liga", "kern"; | |
} | |
/* slight character and word gap of retina devices to make the text more legible */ | |
@media (min-device-pixel-ratio: 2), | |
not all, | |
(min-resolution: 2dppx), | |
(min-resolution: 192dpi) { | |
p, | |
li { | |
letter-spacing: 0.01rem; | |
word-spacing: 0.01rem; | |
} | |
} | |
/* { Box-sizing: Border-box } FTW: http://www.paulirish.com/2012/box-sizing-border-box-ftw/ */ | |
*:not(hr), | |
*:not(hr)::before, | |
*:not(hr)::after { | |
box-sizing: border-box; | |
} | |
input[type=submit], | |
input[type=button], | |
select, | |
a { | |
cursor: pointer; | |
} | |
textarea { | |
resize: vertical; | |
overflow: auto; | |
width: 100%; | |
} | |
/** | |
* Fix the cursor style for Chrome's increment/decrement buttons. For certain | |
* `font-size` values of the `input`, it causes the cursor style of the | |
* decrement button to change from `default` to `text`. | |
*/ | |
input[type="number"]::-webkit-inner-spin-button, | |
input[type="number"]::-webkit-outer-spin-button { | |
height: auto; | |
} | |
/* Remove Search Box Buttons in WebKit: http://davidwalsh.name/remove-search-box-buttons-webkit */ | |
input[type='search']::-webkit-search-decoration, | |
input[type='search']::-webkit-search-cancel-button, | |
input[type='search']::-webkit-search-results-button, | |
input[type='search']::-webkit-search-results-decoration { | |
display: none; | |
} | |
/* remove default webkit form field appearance */ | |
input[type=text], | |
input[type=email], | |
input[type=url], | |
textarea { | |
appearance: none; | |
border-radius: 0; | |
} | |
/* responsive images */ | |
img { | |
max-width: 100%; | |
height: auto; | |
vertical-align: middle; | |
border: 0; | |
} | |
/* | |
* Remove the text shadow on text selections (opinionated). | |
* 1. Restore the coloring undone by defining the text shadow (opinionated). | |
*/ | |
::-moz-selection { | |
/* 1 */ | |
background-color: var(--selection-bg-colour); | |
/* 1 */ | |
color: var(--selection-colour); | |
text-shadow: none; | |
} | |
::selection { | |
/* 1 */ | |
background-color: var(--selection-bg-colour); | |
/* 1 */ | |
color: var(--selection-colour); | |
text-shadow: none; | |
} | |
/* set colour links */ | |
a:link { | |
color: var(--link-colour); | |
} | |
a:visited { | |
color: var(--link-colour); | |
} | |
a:focus { | |
color: var(--link-colour); | |
} | |
a:hover { | |
color: var(--link-colour); | |
} | |
a:active { | |
color: var(--link-colour); | |
} | |
/* selected link */ | |
.hide { | |
display: none; | |
} | |
/* clearfix */ | |
.clearfix::before, | |
.clearfix::after { | |
content: "\0020"; | |
display: block; | |
height: 0; | |
overflow: hidden; | |
} | |
.clearfix::after { | |
clear: both; | |
} | |
.display-flow-root { | |
display: flow-root; | |
} | |
.flex-center: { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
/* new aspect ration techniques here using Grid and SVG: | |
https://justmarkup.com/log/2018/03/collection-of-css-snippets | |
https://codeburst.io/keeping-aspect-ratio-with-html-and-no-padding-tricks-40705656808b */ | |
.old-aspect-ratio.video-wrapper { | |
position: relative; | |
padding-bottom: 56.25%; | |
/* 16:9 */ | |
padding-top: 25px; | |
height: 0; | |
} | |
.old-aspect-ratio.video-wrapper iframe { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
} | |
.ellipsis { | |
max-width: 200px; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
white-space: nowrap; | |
} | |
.truncated { | |
display: block; | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
max-width: 15rem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment