-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSS_Notes.txt
More file actions
270 lines (171 loc) · 4.61 KB
/
Copy pathCSS_Notes.txt
File metadata and controls
270 lines (171 loc) · 4.61 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
*** New Project for CSS ***
1) reset the margin, padding and box-sizing and global html declaration
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
html{
background-color: #fff;
color: #555;
font-family: 'Lato', 'Arial', sans-serif;
font-weight: 300;
font-size: 20px;
text-rendering: optimizeLegibility;
}
2) for html, import normalize css.
<link rel="stylesheet" type="text/css" href="vendors/css/normalize.css">
3) import Grid system.
----------------------------
*** Selector ***
3 types of selector and 4 ways of doing it
- tag selector
- class selector
- class element selector
- id selector
----------------------------
*** Tag Selector ***
Using tag selector, it applies to all items with this tag. example h1
h1 {
color: green;
}
----------------------------
*** class Attribute Selector ***
It is very useful and can applies to all items using this class. Multiple items can use the same class.
You can use multiple classes at once and order doesn't matter.
.book-summary {
color: blue;
}
Example:
.right {
text-align: right;
}
<div class="right"> </div>
<p class="hightlight module right"></p>
----------------------------
*** class element selector style ***
If we don't want to create another class to manage the style of <img> tag, we can use like that. Append the class name with element tag.
<div class="author-box">
<img src="author.jpg" alt="author photo">
<p class='author-text'>Yadana</p>
</div>
.author-box img{
height: 100px;
width: 100px;
border-radius: 50%;
float:left;
}
----------------------------
*** id attribute selector ***
One Unique id attribute selector can only exist in one page. If another item wants to use the same style, it needs to have different unique id name.
#site-description {
color: red;
}
----------------------------
*** CSS Unites ***
2 types => Absolute , Relative
When describing the width of the road,
Absolute is like 7.2 meter
RElative is like 2 cars wide
Abosolute unit in CSS : px, mm, cm, in
Relative unit in CSS: %, em, rem, pt, pc (pica), ex, ch, vw, vh, vmin,vmax
-----------------------------
*** Colors ***
Red 0,255
Green 0,255
Blue 0,255
body{
background-color: rgb(255,0,255);
}
** Transparant Setting as 4th parameter **
rgb(255,0,255,0.45)
** Hexadecimal **
Red 00,FF
Green 00,FF
Blue 00,FF
body{
background-color: #ff00ff;
}
** Shorthand Hexadecimal **
body{
background-color: #00f;
}
------------------------------
** Adding style sheet to HTML **
<head>
<title>My Webpage</title>
<!-- ... -->
<link href="path-to-stylesheet/stylesheet.css" rel="stylesheet">
<!-- ... -->
</head>
----------------------------
*** CSS Box Model ***
Content : text, images, etc
Padding : transparent area around the content, inside the box.
Border : goes around the padding and the content.
Margin : space between the boxes.
box-sizing:boder-box => defining the width and height of the entire box.
---------------------------
*** Two Types of Elements ***
Block Elements : p, div, h1, h2, etc
Inline element : link, underline text, etc
---------------------------
*** Resetting the default margin and padding ***
use the selector * to select all elements
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
---------------------------
*** float ***
With float property, element can be pushed to the left or to the right.
float:left
---------------------------
*** to auto align or center the element **
can use margin-left and margin-right as auto, which will make div or element as center.
.container{
width: 1140px;
margin-left: auto;
margin-right: auto;
}
---------------------------
*** Margin ***
margin: top right bottom left
margin-top: 20px;
margin-left: auto;
margin-right: auto;
is same as
margin: 20px auto 0 auto;
---------------------------
*** Border **
Border can be used to define 3 things.
-border width
-line type
-color
border-top: 1px solid #333; (width,lineType,color)
---------------------------
*** to make image or element round ***
border-radius: 50%;
---------------------------
*** Relative & Absolute Positioning ***
always set the partent class of the absolute class as relative.
.parent{
position: relative;
}
.child{
position: absolute;
}
---------------------------
*** to have slow transitions like button color changing ****
transition: background-color 0.2s, border 0.2s, color 0.2s;
.btn:link,
.btn:visited {
display: inline-block;
padding: 10px 30px;
font-weight: 300;
text-decoration: none;
border-radius: 200px;
transition: background-color 0.2s, border 0.2s, color 0.2s;
}
---------------------------