-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.css
223 lines (165 loc) · 6.05 KB
/
doc.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/* ####################
## SELECTORS
#################### */
/* the selector is used to target an element on a page. */
selector { property: value; /* more properties...*/ }
/*
Here is an example element:
<div class='class1 class2' id='anID' attr='value' otherAttr='en-us foo bar' />
*/
/* You can target it using one of its CSS classes */
.class1 { }
/* or both classes! */
.class1.class2 { }
/* or its name */
div { }
/* or its id */
#anID { }
/* or using the fact that it has an attribute! */
[attr] { font-size:smaller; }
/* or that the attribute has a specific value */
[attr='value'] { font-size:smaller; }
/* starts with a value (CSS 3) */
[attr^='val'] { font-size:smaller; }
/* or ends with a value (CSS 3) */
[attr$='ue'] { font-size:smaller; }
/* or contains a value in a space-separated list */
[otherAttr~='foo'] { }
[otherAttr~='bar'] { }
/* or contains a value in a dash-separated list, e.g., "-" (U+002D) */
[otherAttr|='en'] { font-size:smaller; }
/* You can combine different selectors to create a more focused selector. Don't
put spaces between them. */
div.some-class[attr$='ue'] { }
/* You can select an element which is a child of another element */
div.some-parent > .class-name { }
/* or a descendant of another element. Children are the direct descendants of
their parent element, only one level down the tree. Descendants can be any
level down the tree. */
div.some-parent .class-name { }
/* Warning: the same selector without a space has another meaning.
Can you guess what? */
div.some-parent.class-name { }
/* You may also select an element based on its adjacent sibling */
.i-am-just-before + .this-element { }
/* or any sibling preceding it */
.i-am-any-element-before ~ .this-element { }
/* There are some selectors called pseudo classes that can be used to select an
element only when it is in a particular state */
/* for example, when a link hasn't been visited */
selected:link { }
/* or a link has been visited */
selector:visited { }
/* or an element is in focus */
selected:focus { }
/* or when the cursor hovers over an element */
selector:hover { }
/* or when a link is clicked on */
selector:active { }
/* These pseudo classes regarding links should always be written in the above order or the code might not work as expected */
/* Any element that is the first child of its parent */
selector:first-child {}
/* any element that is the last child of its parent */
selector:last-child {}
/* Just like pseudo classes, pseudo elements allow you to style certain parts of
a document */
/* matches a virtual first child of the selected element */
selector::before {}
/* matches a virtual last child of the selected element */
selector::after {}
/* At appropriate places, an asterisk may be used as a wildcard to select every
element */
* { } /* all elements */
.parent * { } /* all descendants */
.parent > * { } /* all children */
/* Group any number of selectors to define styles that affect all selectors
in the group */
selector1, selector2 { }
/* ####################
## PROPERTIES
#################### */
selector {
/* Units of length can be absolute or relative. */
/* Relative units */
width: 50%; /* percentage of parent element width */
font-size: 2em; /* multiples of element's original font-size */
font-size: 2rem; /* or the root element's font-size */
font-size: 2vw; /* multiples of 1% of the viewport's width (CSS 3) */
font-size: 2vh; /* or its height */
font-size: 2vmin; /* whichever of a vh or a vw is smaller */
font-size: 2vmax; /* or greater */
/* Absolute units */
width: 200px; /* pixels */
font-size: 20pt; /* points */
width: 5cm; /* centimeters */
min-width: 50mm; /* millimeters */
max-width: 5in; /* inches */
/* Colors */
color: #F6E; /* short hex format */
color: #FF66EE; /* long hex format */
color: tomato; /* a named color */
color: rgb(255, 255, 255); /* as rgb values */
color: rgb(10%, 20%, 50%); /* as rgb percentages */
color: rgba(255, 0, 0, 0.3); /* as rgba values (CSS 3) Note: 0 <= a <= 1 */
color: transparent; /* equivalent to setting the alpha to 0 */
color: hsl(0, 100%, 50%); /* as hsl percentages (CSS 3) */
color: hsla(0, 100%, 50%, 0.3); /* as hsl percentages with alpha */
/* Borders */
border-width:5px;
border-style:solid;
border-color:red; /* similar to how background-color is set */
border: 5px solid red; /* this is a short hand approach for the same */
border-radius:20px; /* this is a CSS3 property */
/* Images as backgrounds of elements */
background-image: url(/img-path/img.jpg); /* quotes inside url() optional */
/* Fonts */
font-family: Arial;
/* if the font family name has a space, it must be quoted */
font-family: "Courier New";
/* if the first one is not found, the browser uses the next, and so on */
font-family: "Courier New", Trebuchet, Arial, sans-serif;
}
/* You need to include the css file in your page's <head>. This is the
recommended method. */
<link rel='stylesheet' type='text/css' href='path/to/style.css'>
/* You can also include some CSS inline in your markup. */
<style>
a { color: purple; }
</style>
/* Or directly set CSS properties on the element. */
<div style="border: 1px solid red;">
</div>
/* A */
p.class1[attr='value']
/* B */
p.class1 { }
/* C */
p.class2 { }
/* D */
p { }
/* E */
p { property: value !important; }
<p style='/*F*/ property:value;' class='class1 class2' attr='value'>
/* A rule that will be used on all devices */
h1 {
font-size: 2em;
color: white;
background-color: black;
}
/* change the h1 to use less ink on a printer */
@media print {
h1 {
color: black;
background-color: white;
}
}
/* make the font bigger when shown on a screen at least 480px wide */
@media screen and (min-width: 480px) {
h1 {
font-size: 3em;
font-weight: normal;
}
}
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
</head>