(sort of)
(in short)
Three primary types:
inline
inline-block
block
Internal element space
It is used to ensure content is not at the edges of the given element
External element spacing
It is commonly used to separate elements visually
This is a very useful property in CSS, but it can be tricky
Commonly used for news / articles
Aligning text to the center
Aligning child elements
with margins
margin: 0px auto;
The overflow property
You can specify the direction of the overflow
- overflow-x, overflow-y
/* Adds vertical scrolling */
overflow-y: auto;
/* Hides any overflow */
overflow: hidden;
Only takes effect when the height of the child elements
becomes greater than the height of the parent element
relative
absolute
fixed
Leaves a gap for the element
Does not leave any space for the element
Stays at the same position even when scrolling
Checkout this CSS3 Spinner
It's the CSS3 way to define animations
@keyframes spin {
from {transform:rotate(0deg);}
to {transform:rotate(359deg);}
}
@keyframes spin {
0% { do something; }
25% { do another thing; }
...
100% { get to final "frame" of the animation; }
}
transform everything!
animation-name: spin;
animation-duration: 1000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
Put this into the element you want to animate
Breakdown
@keyframes spin {
from {transform:rotate(0deg);}
to {transform:rotate(359deg);}
}
.spin {
width: 100px;
height: 100px;
background: transparent;
border-radius: 100%;
border-bottom: 2px solid tranparent;
border-left: 1px solid transparent;
border-right: 4px solid #9B59B6;
border-top: 3px solid #9B59B6;
animation-name: spin;
animation-duration: 1000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
Buttons
Navigation Bars / Menus
Form styling and grouping
Pagination
Labels
Lists
Modal Boxes
Tooltips
Colors
It helps make your CSS more modular
Let's take the Spinner and modularize it
/* LESS Example */
@spin-color: #9B59B6;
@spin-size: 100px;
@keyframes spin {
from {transform:rotate(0deg);}
to {transform:rotate(359deg);}
}
.spin {
width: @spin-size;
height: @spin-size;
background: transparent;
border-radius: 100%;
border-bottom: 2px solid tranparent;
border-left: 1px solid transparent;
border-right: 4px solid @spin-color;
border-top: 3px solid @spin-color;
animation-name: spin;
animation-duration: 1000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
This is an example of overriding bootstrap's LESS variables
/* Bootstrap has these variables:
* @brand-primary
* @brand-success
* @brand-info
* @brand-warning
* @brand-danger
* and many more
*/
@brand-primary: green;
@brand-info: purple;
@brand-danger: red;
https://github.com/rgoomar/CSS-Crash-Course