A Flex is used to design responsive websites. Flex is a CSS3 shorthand property. We can use a flexible container by setting the flex value to display property.
What is CSS3 Flexible Container Layout?
CSS3 Flexible layout is used to design flexible responsive layouts for different devices. We can easily design a website with different views by using CSS3 display: flex property.
<style>
.tdb-flex{
display:flex;
}
</style>
<body>
<div class="tdb-height">
<div class="tdb-div1">DIV1</div>
<div class="tdb-div2">DIV2</div>
</div>
</body>
Note: You can also use Grid Layout for resposive web designs.
<!DOCTYPE html>
<html>
<head>
<style>
.tdb-flex{
display:flex;
color:white;
padding:10px;
text-align:center
}
.tdb-div1{background-color:red;
width:50%}
.tdb-div2{background-color:black;
width:50%}
</style>
</head>
<body>
<div class="tdb-flex">
<div class="tdb-div1">DIV1</div>
<div class="tdb-div2">DIV2</div>
</div>
</body>
</html>
These are the properties we use for a flexible layouts.
<style>
.tdb-flex{
display:flex;
flex-direction: column;
}
</style>
Note: You can also use Grid Layout for resposive web designs
<!DOCTYPE html>
<html>
<head>
<style>
.tdb-flex{
display:flex;
padding:10px;
text-align:center;
flex-direction: column;
}
.tdb-div1,.tdb-div3{background-color:pink;
width:50%}
.tdb-div2{background-color:orange;
width:50%}
</style>
</head>
<body>
<div class="tdb-flex">
<div class="tdb-div1">DIV1</div>
<div class="tdb-div2">DIV2</div>
<div class="tdb-div3">DIV3</div>
</div>
</body>
</html>