2024 CSS Cheatsheet - SheCodes
2024 CSS Cheatsheet - SheCodes
io/css
Search cheatsheets..
Selectors Colors
a{ p{
color: red; color: #00ff00;
} }
h1 {
text-align: center; More info
}
.header {
Class selector background: green; Copy code
}
/* All elements with class="spacious" */ You can also use an image as a background.
.spacious {
More info
margin: 20px;
}
h1 {
/* All <li> elements with a class list that includes both "spacious" and "elegant" */
color: blueviolet;
/* For example, class="elegant retro spacious" */
}
li.spacious.elegant {
margin: 20px;
} Note: We generally only use black or white. Other colors such as red, blue, green are only good for testing purposes. You should u
Hexadecimal colors
More info CSS
h1 {
color: #885df1;
}
ID selector Copy code
1 of 8 2024-10-01, 19:27
2024 CSS Cheatsheet | SheCodes http://cheatsheets.shecodes.io/css
a:visited {
color: red;
} /* without transparency */
p{
color: rgb(135, 93, 241);
More info } CSS
/* with transparency */
h1 {
Box }
color: rgba(135, 93, 241, 0.5);
Gradient
First value is the thickness, second one the style (none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset), and third one is the color.
.footer {
background: linear-gradient(#e66465, #9198e5);
}
body {
background-image: url("https://i.notretemps.com/1400x787/smart/2022/06/13/albi.jpeg");
Padding Copy code
background-repeat: no-repeat;
background-size: cover;
background-color: black;
/* padding around the element */
}
.box-1 {
padding: 10px;
} More info
Width h1 {
Copy code
text-decoration: underline;
}
.box-1 {
width: 100%; none: no line is drawn, and any existing decoration is removed. underline: draws a 1px line across the text at it
}
text at its “middle” point. overline: draws a 1px line across the text, directly above its “top” point. inherit: inher
2 of 8 2024-10-01, 19:27
2024 CSS Cheatsheet | SheCodes http://cheatsheets.shecodes.io/css
}
text at its “middle” point. overline: draws a 1px line across the text, directly above its “top” point. inherit: inher
.box-3 {
min-width: 200px; Text transform
}
h1 {
More info CSS
text-transform: uppercase;
}
.box-1 {
height: 100%;
}
Line height
.box-2 {
max-height: 100px;
} h1 {
line-height: 28px;
.box-3 { }
min-height: 200px;
} p{
font-size: 14px;
line-height: 1.5;
More info } CSS
Note: We generally use a multiplier such as 1.5 which making the line height 1.5 times higher than the font size
h1 {
font-style: italic;
/* Rounded corner top left and right only */
}
.box-2 {
border-radius: 50% 50% 0 0;
} Note: font-style: normal | italic | oblique | initial | inherit;
More info
The border-radius CSS property rounds the corners of an element's outer border edge.
Font weight
Note: font-weight: normal | bold | bolder | lighter | number | initial | inherit; It can also be a value between 100 | 200 | 300 | 40
Transform extra bold Copy code
More info
/* Function values */
transform: rotate(0.5);
transform: rotateX(10deg);
transform: rotateY(10deg);
Font size
transform: rotateZ(10deg);
transform: translate(12px, 50%);
transform: translate3d(12px, 50%, 3em);
body {
transform: translateX(2em);
font-size: 18px;
transform: translateY(3in);
}
transform: translateZ(2px);
transform: scale(2, 0.5);
transform: skew(30deg, 20deg);;
More info
3 of 8 2024-10-01, 19:27
2024 CSS Cheatsheet | SheCodes http://cheatsheets.shecodes.io/css
body {
font-family: Georgia, serif;
}
More info
List
Note: Each element is by default inline or block element. A block element creates an invisible line before and after. An inline elem
Mouse
More info
Position
button:hover {
cursor: pointer;
}
.heading {
position: relative;
auto | default | none | context-menu | help | pointer | progress | waittop:
| cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | e-
-10px;
left:
resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize 20px;
| w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-
}
scroll | zoom-in | zoom-out | grab | grabbing
Center element
:root {
--main-branding-color: #885df1;
}
h1 { Flexbox
color: var(--main-branding-color);
}
.container {
display: flex;
Note: Useful to store font families, colors or sizes. flex-direction: row | row-reverse | column | column-reverse; /* optional */
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right
More info CSS
flex-direction: row | column; /* optional */
}
.footer { img {
display: none; max-width: 100%;
} height: auto;
} }
4 of 8 2024-10-01, 19:27
2024 CSS Cheatsheet | SheCodes http://cheatsheets.shecodes.io/css
Grids
Media queries are useful when you want to apply CSS to specific resolution breakpoints to make your website more responsive.
More info
a{
transition: all 200ms ease;
opacity: 1;
color: blue;
}
a:hover {
opacity: 0.7;
color: red;
}
5 of 8 2024-10-01, 19:27