CSS Basics
CSS Basics
Selectors_________________________________________________________________ 2
2. Box Model________________________________________________________________ 2
3. Display Property___________________________________________________________ 2
4. Positioning_______________________________________________________________ 3
5. Floats and Clearing________________________________________________________ 4
6. CSS Flexbox Layout________________________________________________________4
7. CSS Grid Layout___________________________________________________________ 5
8. Responsive Design and Media Queries________________________________________ 5
9. CSS Transitions and Animations_____________________________________________ 5
10. Pseudo-classes and Pseudo-elements_______________________________________ 6
11. Specificity and Inheritance_________________________________________________ 6
12. Units of Measurement_____________________________________________________ 7
13. CSS Preprocessors_______________________________________________________ 7
14. Vendor Prefixes and Browser Compatibility___________________________________ 7
15. CSS Frameworks_________________________________________________________ 8
16. CSS Methodologies_______________________________________________________ 8
17. CSS Variables (Custom Properties)__________________________________________ 8
1. Selectors
Class Selector: Targets elements with a specific class attribute.
2. Box Model
The box model includes margin, border, padding, and content.
3. Display Property
Block: The element takes up the full width.
4. Positioning
Static: Default position, elements are placed in the normal document flow.
.btn:hover {
background-color: darkblue;
}
Animations: More complex, allows keyframe-based animations.
.ball {
animation: bounce 2s infinite;
}
.container p {
/* inherits font-family from .container */
}
12. Units of Measurement
Pixels (px): Absolute unit.
Ems (em): Relative to the font-size of the element.
Rems (rem): Relative to the font-size of the root element.
Percentages (%): Relative to the parent element.
.nav {
background-color: $primary-color;
ul {
list-style: none;
li {
display: inline-block;
}
}
}
Ensuring styles work across different browsers.
.header {
background-color: var(--primary-color);
}
These examples provide a glimpse into how each CSS concept can be applied in real-world