Cheatography
https://cheatography.com
Tout le nécessaire pour faire un bon styling basique
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Basic Syntax
h1 {
color: red;
text-align: center;
}
//{property: value;}
|
Ways to add CSS styling
External |
<link rel="stylesheet" href="styles.css">
|
Internal |
<style> h1 { color: blue; } </style>
|
Inline |
<h1 style="color: red;">Hello</h1>
|
Text Formatting
Font size : (absolute) |
|
Font size : (relative) |
|
Font family |
font-family: Arial, sans-serif;
|
Font style |
|
Font weight |
|
Text alignement |
text-align: left | center | right | justify;
|
Text decoration |
text-decoration: underline | line-through | overline | none;
|
Colors & Background
Text color |
|
Background color |
background-color: #f0f0f0;
|
Background image |
background-image: url('image.jpg');
|
Background repeat |
background-repeat: no-repeat | repeat-x | repeat-y;
|
Background position |
background-position: center center;
|
Fixed background |
background-attachment: fixed;
|
Borders & Shadows
Border |
|
Border radius |
|
Box Shadow |
box-shadow: 5px 5px 10px gray;
|
Text Shadow |
text-shadow: 2px 2px 4px black;
|
Selectors
Element selector |
|
Class selector |
|
ID selector |
#main { font-size: 20px; }
|
Group selector |
h1, h2, p { color: red; }
|
Child selector |
|
Adjacent sibling selector |
|
Universal selector |
* { margin: 0; padding: 0; }
|
Attribute selector |
input[type="text"] { border: 1px solid blue; }
|
Pseudo-classes & Elements
hover |
a:hover { color: orange; }
|
First child |
p:first-child { font-weight: bold; }
|
First letter |
p::first-letter { font-size: 2em; }
|
Before content |
h1::before { content: "★"; }
|
.
Margin |
|
Padding |
|
Width |
|
Height |
|
Border |
|
Position Types
|
default |
|
relative to itself |
|
relative to parent |
|
relative to viewport |
|
moves within a container |
Display
|
default for div,p,h1 |
|
for span , a |
|
inline + block |
|
hiding element |
z-index
controls layer order (it's like a 3rd dimension for the page) |
|
|
Float & Clear
Float : |
|
Clear |
clear: left | right | both;
|
|
|
|