-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathapp-reset.css
138 lines (116 loc) · 4.1 KB
/
app-reset.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
# App reset by Ben Frain @benfrain / benfrain.com
An opinionated set of resets suitable for building web applications.
Latest: https://github.com/benfrain/app-reset
# Accessibility Notes
These resets target HTML elements that typically receive styling defaults by User Agents that I always need to 'undo'.
Be aware that some of these resets have a negative impact on the default usability and accessibility of a web page. Therefore, ensure you add an equivalent accessible style back that matches your project aesthetic.
You may want to run this through Autoprefixer (https://github.com/postcss/autoprefixer) for production.
*/
/* Allows height/width animations to auto across document */
:root {
interpolate-size: allow-keywords;
}
html {
/*Hat tip to @thierrykoblentz for this approach: https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */
box-sizing: border-box;
--fontStack: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI",
Tahoma, Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Open Sans",
sans-serif;
font-family: var(--fontStack);
}
/*Yes, the universal selector. No, it isn't slow: https://benfrain.com/css-performance-revisited-selectors-bloat-expensive-styles/*/
* {
/*This prevents users being able to select text. Stops long presses in iOS bringing up copy/paste UI for example*/
user-select: none;
/* Most devs find border-box easier to reason about. However by inheriting we can mix box-sizing approaches.*/
box-sizing: inherit;
}
*:before,
*:after {
box-sizing: inherit;
}
body,
h1,
h2,
h3,
h4,
h5,
h6,
p {
/*We will be adding our own margin to these elements as needed.*/
margin: 0;
/*You'll want to set font-size as needed.*/
font-size: 1rem;
/*No bold for h tags unless you want it*/
font-weight: 400;
}
a {
text-decoration: none;
color: inherit;
}
/*No bold for b tags by default*/
b {
font-weight: 400;
}
/*Prevent these elements having italics by default*/
em,
i {
font-style: normal;
}
/*IMPORTANT: This removes the focus outline for most browsers. Be aware this is a backwards accessibilty step!*/
a:focus,
button:focus {
outline: 0;
}
/* The button element tends to get a lot of default styles which we largely undo here. We set text-alignment (usually set to center by UA style sheet) and the font-family to inherit from your own styles instead. */
button {
appearance: none;
background-color: transparent;
border: 0;
padding: 0;
text-align: inherit;
font-family: inherit;
font-weight: inherit;
font-size: inherit;
/* Safari adds margin */
margin: 0;
}
button:hover {
cursor: pointer;
}
input,
fieldset {
appearance: none;
border: 0;
padding: 0;
margin: 0;
/*inputs and fieldset defaults to having a min-width equal to its content in Chrome and Firefox (https://code.google.com/p/chromium/issues/detail?id=560762), we may not want that*/
min-width: 0;
/*Reset the font size and family*/
font-size: inherit;
font-family: inherit;
}
/*This switches the default outline off when an input receives focus (really important for users tabbing through with a keyboard) so ensure you put something decent in for your input focus instead!!*/
input:focus {
outline: 0;
}
/*Removes the little spinner controls for number type inputs (WebKit browsers/forks only)*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
appearance: none;
}
/*SVG defaults to display: inline which I dislike. Inline-block or inline-flex will render white space on SVG elements in HTML (where you would have defs and symbols) if the container isn't a flex box or the font-size set to 0 to crush the whitespace */
svg {
display: block;
}
img {
/*Make images behave responsively. Here they will scale up to 100% of their natural size*/
max-width: 100%;
/*Make images display as a block (UA default is usually inline)*/
display: block;
}
/* Switching on box-sizing: border-box by default; toggle this off if you want more granular control */
body {
box-sizing: border-box;
}