Css
Css
CSS Page 1
Car class is dependent on pet/De engine ?
Petrol
Diesel
start
CSS Page 2
Fonts Family :
CSS Page 3
Properties with fonts:
Line-height
-----------
Using this tag each line will follow this unit
Text-align
----------
Used to align text on screen
Note : text-align always start from left side by default
CSS Page 4
padding
margin
sets whether an element is treated as a block or inline box and the layout used for its children
What is block : in html each tag have their nature like inline or block just like div and span
Eg: if you h1 and again h1 both will come one by one it's called block nature
h1
h2
CSS Page 5
By default nature
Note: If an element is a block-level element, it takes up the entire width of the row, and no other elements can appear beside it—just like a lion in the
jungle, ruling over its space alone (similar to how only one block-level element fits in a row).
but when we make block and inline-block the it will allow other elements can appear beside it
Inline elements allow other elements can appear beside it if these is space
on the other hand, are like monkeys—they're flexible and allow other elements to sit beside them in the same line, leaving space around them.
If you make any element inline then you cannot change it's width and height
Position:
CSS Page 6
position: relative
Note: If we make parent position relative then child will take property from parent not screen
CSS Page 7
Genie
Genie Ashwani
Ashwani
inline
CSS Page 8
CSS Page 9
Flex : when we want element side by side them flex is better choice as compare to inline, because we have more
control over element
When you apply Flexbox, two axes get activated automatically: the main axis and the cross axis. These axes control how
the flex items are laid out inside the flex container
1. Main Axis
The main axis is the primary direction in which the flex items are laid out. By default, when you apply display: flex, the
main axis runs horizontally from left to right (because flex-direction: row is the default).
2. Cross Axis
The cross axis is always perpendicular to the main axis. If the main axis is horizontal (in a row layout), the cross axis is
vertical. If the main axis is vertical (in a column layout), the cross axis is horizontal.
Main Axis: Controls the flow of items (horizontally or vertically, depending on flex-direction).
Cross Axis: Handles the alignment of items perpendicular to the main axis (vertically if in a row, horizontally if in a
column).
CSS Page 10
items inside a container
.container {
display: flex;
flex-direction: row;
}
.container {
display: flex;
align-items: center; ////work with cross axis
}
1. Handling Wrapping : If you have too many items to fit in a row, you might want them to wrap onto a new line rather
than squish together.
.container {
display: flex;
flex-wrap: wrap; /* Now the items will wrap to a new line if needed */
}
.item {
flex-grow: 1;
flex-shrink: 0;
flex-basis: 100px;
}
CSS Page 11
○ flex-start: Aligns items to the start of the container.
○ flex-end: Aligns items to the end of the container.
○ center: Aligns items in the center.
○ space-between: Evenly distributes items with space between them.
○ space-around: Items have space around them, including outside edges.
4. align-items: Aligns items along the cross axis (vertical in row direction).
○ stretch (default): Items stretch to fill the container.
○ flex-start: Aligns items to the start of the cross axis.
○ flex-end: Aligns items to the end of the cross axis.
○ center: Centers items along the cross axis.
○ baseline: Aligns items along their text baselines.
5. align-content: Controls the alignment of items when there is extra space in a multi-line flex container (when flex-wrap is used).
○ Works similarly to justify-content but for the cross axis.
6. flex-wrap: Determines whether items should wrap onto multiple lines.
○ nowrap (default): All items are on one line.
○ wrap: Items wrap to the next line if they can’t all fit on one line.
○ wrap-reverse: Items wrap in reverse order.
7. gap: Specifies the space between flex items. Previously handled by margins, gap makes it easier to add spacing between rows and
columns.
In CSS, both pseudo-elements and pseudo-classes are used to style specific parts or states of elements,
but they do this in different ways:
• Pseudo-classes: These apply styles to an element based on its state or condition, such as when an element is hovered over, focused, or
even its position relative to siblings.
• Pseudo-elements: These allow you to style specific parts of an element, like the first letter, first line, or even inserting new content
before or after the element’s content.
Common Pseudo-classes:
button:hover {
background-color: lightblue;
}
input:focus {
border-color: green;
}
li:nth-child(2) {
color: red;
}
p:first-child {
font-weight: bold;
}
a:active {
color: red;
}
Common Pseudo-elements:
h1::before {
content: ' ';
color: orange;
}
h1::after {
content: ' ';
}
p::first-line{
font-size: 2em;
color: red;
}
::selection {
CSS Page 12
::selection {
background-color: yellow;
color: black;
}
Display: grid
headers
sidebar content
footer
1D
3*3 = 2D
CSS Page 13
CSS Page 14
CSS Page 15