Day 22: flexbox
flex-diection:
flex-wrap: wrap;
justify-content: flex-start;
- Flexbox property :
- Inline-flex :
- To make a flex container as an inline-level flex element, use the following syntax :
container
{
display: inline-flex;
}
Using inline-flex, an element is displayed on the same line as the others. Since it follows the height and width of the line of which it is a part, specifying any height and width parameters will be useless, whereas display:flex, takes up the entire available width.
Example :
1. Using display:inline-flex (takes up limited width)
2. Using display: flex (takes up entire available width)
Other flex properties to explore :
- Flex-direction : Defines direction of flex items present inside the flex container.
Values :
- row
- row-reverse
- column
- column-reverse
Example :
Flex-direction : column-reverse;
gives the following output :
Code :
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: inline-flex;
flex-direction: column-reverse;
background-color: rgb(220, 165, 165);
padding: 10px;
}
.item {
background-color: rgba(255, 255, 255, 0.8);
border: 1px dashed rgba(63, 187, 200, 0.8);
text-align: center;
padding: 20px;
font-size: 30px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">flex item 1</div>
<div class="item">flex item 2</div>
<div class="item">flex item 3</div>
<div class="item">flex item 4</div>
<div class="item">flex item 5</div>
<div class="item">flex item 6</div>
<div class="item">flex item 7</div>
<div class="item">flex item 8</div>
<div class="item">flex item 9</div>
</div>
</body>
</html>
Try out the various other values for flex-direction and observe the output.
- Flex-wrap : wraps the items as per the value assigned to flex-wrap property.
Values to try :
- nowrap
- wrap
- wrap-reverse
3. Justify-content :
Values to try :
- flex-start
- flex-end
- start
- end
- left
- right
- center
- space-between
- space-around
- space-evenly
Comments
Post a Comment