dont-forget-css this one
dont-forget-css this one
Fundamentals
Margin
Border
Padding
The Box Model Content
Specificity
MOST LEAST
SPECIFIC SPECIFIC
Sizing
Pixels
REM
Percent
A percentage
Colors
Color words:
black
cadetblue Not the best colors, but fast to
write. Useful to test things, but
orangered not much else
parchment
Hex codes:
#00 00 00 black
Each 2 digits represents red,
R G B green, and blue with values 0-f
#ff ff ff white
R G B
R G B
RGB function
rgb( 0, 0, 0 ) black
Same as hex, but with RGB
rgb(255, 255, 255) white values represented as 0-255.
rgb(255, 0, 0 ) pure red
RGBA codes
Selectors
Basics
HTML Elements
h1 {
Simply the name of the element
}
Classes
.secondary {
Use the dot prefix
}
Ids
#name {
Use the hash prefix
}
Combining Selectors
Comma
h1, h2, h3 {
To select multiple
}
ol > li {
All li directly inside ol
}
.hero p {
All p inside hero class
}
Advanced Selectors
Pseudo classes
button:hover {
Add to the end of your selector
with a colon, these allow you to
} select an element by its 'state'
( ex :hover ), or position within
the document tree ( ex :nth-of-
div:nth-of-type(2) { type(2) )"
Pseudo elements
Lets you style a specific part of
::before { an element, and in certain cases
add cosmetic content (ex ::before
} to change bullet points
Compound selectors
Chain together as many selectors,
.container > div:hover { and pseudo classes as you want
to get extremely specific. You can
} always see the specificity by
hovering over in VS code
Properties
Some of the most common properties.
Remember, key names separated by hyphen, values without
quotations, end lines with semicolon.
Text
Font size
h1 {
font-size: 20px; Can use any size value
}
Color
h2 {
color: white; Is just “color” (not text-color)
}
Font family
h3 {
Can be a single name, or comma
font-family: Helvetica, separated priority list.
sans-serif;
}
Font weight
h4 {
font-weight: bold; Can take a word, or a value 1-900
font-weight: 400;
}
h5 {
Used for underlining text, and
text-decoration: underline; italicizing text, in most cases
font-style: italic;
}
Font shorthand
p {
Combine multiple font properties
font: italic 1.2em "Fira Sans", into a single line
serif;
}
Spacing
.box {
Can use any size value, but
width: 100%; percentages are recommended
height: 20%;
}
.container {
Can use (1) single values, (2)
margin-left: 20px; /* (1) */ all 4 side value, (3) top+bottom
padding: 5px; /* (2) */ values, (4) explicit 4 side values
margin: 20px 10px; /*( 3) */
padding: 5px 10px 20px 10px ;/* (4) */ ( ! ) Don't forget
} padding = inside border &
painted by background color
margin = outside border
Border
.block {
Syntax = size, type, color
border: 1px solid grey; (almost always solid)
}
Box-sizing
.shape {
Defines whether padding and
box-sizing: border-box;/* yes */ border are included in width
box-sizing: content-box;/* no */
}
Background
Background Color
Background Image
Background shorthand
Position, Display
.item {
position: absolute;
left: 50%;
top: 50%;
}
Display
Flexbox
Display flex
Flex wrap
.box {
width: 30%; /* fixed size = 3
per line, then wrap */
}
Flex Direction
Media Queries
Opacity
Transition
Transform
.logo {
animation-name: spin;
animation-duration: 5000ms;
animation-iteration-count:
infinite;
animation-timing-function:
linear;
}
.logo {
You can also use the animation
animation: spin 5s infinite 1s; shorthand
}
@aaronjack @coding_with_jan
The Freelance Developer Bootcamp