CSS - clear
clear
modifies the side of an element that other floating elements are no longer allowed to float. can be used after a row of floating elements.
none|left|right|both|initial|inherit
Property Variable Name
clear
Available Values for clear
none|left|right|both|initial|inherit
Examples Using clear values
Example using clear none
Example using clear none
Here is an example using different clear values
Demo Box 1 Content 1
Demo Box 1 Content 1
Code
<style>
.demo-box-1 {
position:relative;
border-radius:3px;
margin-bottom:10px;
border:1px solid #000;
height:240px;
width:100%;
transition: all 0.3s;
}
.demo-box-1 .dbs-1,
.demo-box-1 .dbs-2
{
font-size:14px;
transition: all 0.3s;
display:block;
padding:10px;
background:#3b7aa0;
color:#FFF;
margin:0 1%;
height:120px;
width:120px;
box-shadow:0px 5px 10px #000;
border:3px solid #EEE;
border-radius:3px;
}
.demo-box-1 .dbs-1 {
float:left;
transition: all 0.3s;
}
.demo-box-1 .dbs-2 {
float:left;
transition: all 0.3s;
clear:none;
}
</style>
<h2>Example using clear none</h2>
<p>Here is an example using different clear values</p>
<div class='demo-box-1'>
<div class='dbs-1'>Demo Box 1 Content 1</div>
<div class='dbs-2'>Demo Box 1 Content 1</div>
</div>
Example using clear left
Example using clear left
Here is an example using different clear values
Demo Box 2 Content 1
Demo Box 2 Content 1
Code
<style>
.demo-box-2 {
position:relative;
border-radius:3px;
margin-bottom:10px;
border:1px solid #000;
height:240px;
width:100%;
transition: all 0.3s;
}
.demo-box-2 .dbs-1,
.demo-box-2 .dbs-2
{
font-size:14px;
transition: all 0.3s;
display:block;
padding:10px;
background:#3b7aa0;
color:#FFF;
margin:0 1%;
height:120px;
width:120px;
box-shadow:0px 5px 10px #000;
border:3px solid #EEE;
border-radius:3px;
}
.demo-box-2 .dbs-1 {
float:left;
transition: all 0.3s;
}
.demo-box-2 .dbs-2 {
float:left;
transition: all 0.3s;
clear:left;
}
</style>
<h2>Example using clear left</h2>
<p>Here is an example using different clear values</p>
<div class='demo-box-2'>
<div class='dbs-1'>Demo Box 2 Content 1</div>
<div class='dbs-2'>Demo Box 2 Content 1</div>
</div>
Example using clear right
Example using clear right
Here is an example using different clear values
Demo Box 3 Content 1
Demo Box 3 Content 1
Code
<style>
.demo-box-3 {
position:relative;
border-radius:3px;
margin-bottom:10px;
border:1px solid #000;
height:240px;
width:100%;
transition: all 0.3s;
}
.demo-box-3 .dbs-1,
.demo-box-3 .dbs-2
{
font-size:14px;
transition: all 0.3s;
display:block;
padding:10px;
background:#3b7aa0;
color:#FFF;
margin:0 1%;
height:120px;
width:120px;
box-shadow:0px 5px 10px #000;
border:3px solid #EEE;
border-radius:3px;
}
.demo-box-3 .dbs-1 {
float:left;
transition: all 0.3s;
}
.demo-box-3 .dbs-2 {
float:left;
transition: all 0.3s;
clear:right;
}
</style>
<h2>Example using clear right</h2>
<p>Here is an example using different clear values</p>
<div class='demo-box-3'>
<div class='dbs-1'>Demo Box 3 Content 1</div>
<div class='dbs-2'>Demo Box 3 Content 1</div>
</div>
Example using clear both
Example using clear both
Here is an example using different clear values
Demo Box 4 Content 1
Demo Box 4 Content 1
Code
<style>
.demo-box-4 {
position:relative;
border-radius:3px;
margin-bottom:10px;
border:1px solid #000;
height:240px;
width:100%;
transition: all 0.3s;
}
.demo-box-4 .dbs-1,
.demo-box-4 .dbs-2
{
font-size:14px;
transition: all 0.3s;
display:block;
padding:10px;
background:#3b7aa0;
color:#FFF;
margin:0 1%;
height:120px;
width:120px;
box-shadow:0px 5px 10px #000;
border:3px solid #EEE;
border-radius:3px;
}
.demo-box-4 .dbs-1 {
float:left;
transition: all 0.3s;
}
.demo-box-4 .dbs-2 {
float:left;
transition: all 0.3s;
clear:both;
}
</style>
<h2>Example using clear both</h2>
<p>Here is an example using different clear values</p>
<div class='demo-box-4'>
<div class='dbs-1'>Demo Box 4 Content 1</div>
<div class='dbs-2'>Demo Box 4 Content 1</div>
</div>
Example using clear initial
Example using clear initial
Here is an example using different clear values
Demo Box 5 Content 1
Demo Box 5 Content 1
Code
<style>
.demo-box-5 {
position:relative;
border-radius:3px;
margin-bottom:10px;
border:1px solid #000;
height:240px;
width:100%;
transition: all 0.3s;
}
.demo-box-5 .dbs-1,
.demo-box-5 .dbs-2
{
font-size:14px;
transition: all 0.3s;
display:block;
padding:10px;
background:#3b7aa0;
color:#FFF;
margin:0 1%;
height:120px;
width:120px;
box-shadow:0px 5px 10px #000;
border:3px solid #EEE;
border-radius:3px;
}
.demo-box-5 .dbs-1 {
float:left;
transition: all 0.3s;
}
.demo-box-5 .dbs-2 {
float:left;
transition: all 0.3s;
clear:initial;
}
</style>
<h2>Example using clear initial</h2>
<p>Here is an example using different clear values</p>
<div class='demo-box-5'>
<div class='dbs-1'>Demo Box 5 Content 1</div>
<div class='dbs-2'>Demo Box 5 Content 1</div>
</div>
Example using clear inherit
Example using clear inherit
Here is an example using different clear values
Demo Box 6 Content 1
Demo Box 6 Content 1
Code
<style>
.demo-box-6 {
position:relative;
border-radius:3px;
margin-bottom:10px;
border:1px solid #000;
height:240px;
width:100%;
transition: all 0.3s;
}
.demo-box-6 .dbs-1,
.demo-box-6 .dbs-2
{
font-size:14px;
transition: all 0.3s;
display:block;
padding:10px;
background:#3b7aa0;
color:#FFF;
margin:0 1%;
height:120px;
width:120px;
box-shadow:0px 5px 10px #000;
border:3px solid #EEE;
border-radius:3px;
}
.demo-box-6 .dbs-1 {
float:left;
transition: all 0.3s;
}
.demo-box-6 .dbs-2 {
float:left;
transition: all 0.3s;
clear:inherit;
}
</style>
<h2>Example using clear inherit</h2>
<p>Here is an example using different clear values</p>
<div class='demo-box-6'>
<div class='dbs-1'>Demo Box 6 Content 1</div>
<div class='dbs-2'>Demo Box 6 Content 1</div>
</div>