2-htmlcss Modules
2-htmlcss Modules
Table Of Content
1 / 20
NgNinja Academy | All Rights Reserved
Id and Class
Element and Class
Advanced Selectors
adjacent selector
attributes selector
Backgrounds
Colors
Borders
Fun with Border Radius
Shapes
Shorthand
Circle and leaf
Circle
Leaf
Module 3 - Display and position your elements
Box model
Total width of an element should be calculated like this:
Total height of an element should be calculated like this:
Margins
Margin On Individual Sides
Margin Shorthands
Auto Margin
Paddings
Padding On Individual Sides
Padding Shorthands
Display
Block
Inline
Inline-block
None
Visibility Hidden
Flex
Positions
Static
Relative
Absolute
Fixed
Centering:
Centering Vertically
CSS Float
Clearing Floats
Methods to clear oat:
Module 4 - Semantic HTML5
Semantic HTML?
More about Semantic HTML
Di erence between HTML and HTML5?
2 / 20
NgNinja Academy | All Rights Reserved
HTML
HTML 5
Below are new semantic elements
What elements have disappeared in the latest HTML?
Di erence between <div> and <frame>?
What is HTML5 Web Storage?
localStorage:
sessionStorage:
Module 5 - Flexbox intro and media query
Flexbox
Flex box container properties
Flex box item properties
Flexbox Examples
Media queries
Always Design for Mobile First
Orientation: Portrait / Landscape
Let's talk about the sizes - px vs em vs rem
How to calculate PX from REM
More on rem vs em
CSS Grids
Flexbox
Grids
Example
Example #2 - Gaps
Example #3 - Fractions
Example #4 - Fractions Contd.
Nested grids
Start-End points of Grid
Module 6 - Quirks, tips, and tricks
FOUC
How to avoid it?
BEM naming convention
OOCSS - Object Oriented CSS
CSS User Agent Styles
Normalizing CSS
Reset CSS
Validate your CSS
Testing Strategies
Conditional CSS
3 / 20
NgNinja Academy | All Rights Reserved
4 / 20
NgNinja Academy | All Rights Reserved
.card {
border: 10px solid #E53038;
height: 300px;
width: 300px;
padding: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
5 / 20
NgNinja Academy | All Rights Reserved
Shapes
Borders also take another property called border-radius using which you can give di erent
shapes to your elements
In the above illustration we have a square on the left and circle on the right
If you provide border-radius of 50% it will turn your square into a circle
.square {
border-radius: none;
}
.circle {
border-radius: 50%;
}
6 / 20
NgNinja Academy | All Rights Reserved
Shorthand
7 / 20
NgNinja Academy | All Rights Reserved
// all 4 corners
.one {
border-radius: 50%;
}
.card {
border: 10px solid #E53038;
height: 100px;
width: 100px;
padding: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 20px;
}
8 / 20
NgNinja Academy | All Rights Reserved
Circle
.circle {
border-radius: 50%;
}
9 / 20
NgNinja Academy | All Rights Reserved
Leaf
.leaf {
border-radius: 5px 20px 5px;
}
10 / 20
NgNinja Academy | All Rights Reserved
Paddings
Paddings are used to generate space around the given element's content - inside its border
<div class="myDiv">
<p>My Paragraph</p>
</div>
// styles
.myDiv {
padding: 20px;
}
11 / 20
NgNinja Academy | All Rights Reserved
You can also give padding to the elements on any particular side if you'd want
padding-top
padding-right
padding-bottom
padding-left
Padding Shorthands
div {
padding: 20px;
}
div {
padding: 20px 40px;
}
12 / 20
NgNinja Academy | All Rights Reserved
div {
padding: 20px 40px 50px;
}
13 / 20
NgNinja Academy | All Rights Reserved
Display
Block
Inline
14 / 20
NgNinja Academy | All Rights Reserved
Inline-block
None
Visibility Hidden
div {
visibility: hidden;
}
Flex
15 / 20
NgNinja Academy | All Rights Reserved
Flex property gives ability to alter its item's width/height to best ll the available space
It is used to accommodate all kind of display devices and screen sizes
Fills available space
Or shrink to prevent over ow
16 / 20
NgNinja Academy | All Rights Reserved
localStorage:
// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
document.getElementById("result").innerHTML =
localStorage.getItem("lastname");
17 / 20
NgNinja Academy | All Rights Reserved
sessionStorage:
if (sessionStorage.clickcount) {
sessionStorage.clickcount = Number(sessionStorage.clickcount) + 1;
} else {
sessionStorage.clickcount = 1;
}
18 / 20
NgNinja Academy | All Rights Reserved
If you’re setting all of your font-sizes, element sizes and spacing in pixels, you’re not treating the
end user with respect.
Users will have to zoom in and out with ctrl plus +/- depending on the device they are on
REMs are a way of setting font-sizes based on the font-size of the root HTML element
Allows you to quickly scale an entire project by changing the root font-size
Both pixels and REMs for media queries fail in various browsers when using browser zoom, and
EMs are the best option we have.
19 / 20
NgNinja Academy | All Rights Reserved
Normalizing CSS
Reset CSS
This approach says that we don’t need the browsers’ default styles at all
We’ll de ne in the project according to our needs
CSS Reset resets all of the styles that come with the browser’s user agent
Grab sample CSS reset here
The problem with CSS Resets is that they are ugly and hard to debug
Solution - use Normalize CSS with little bit of CSS Reset
Unlike an ordinary CSS reset, target speci c HTML tags’ styles rather than making a big list of tags.
Make it less aggressive and a lot more readable
20 / 20