I want create a responsive columns using HTML/CSS with float property only and it is working but I'm not able to put the background color in it.
I tried applying a background color in whole section using CSS but it is not getting applied. Is there any way I can add a background color in section not individually in columns?
/*Section with background color - Red*/
.section {
width: 100%;
background-color: red;
}
/*Column with 50% width*/
.column {
width: 50%;
float: left;
}
/*Media query to make it responsive breakpoint at 800px*/
@media screen and (max-width: 800px) {
.column {
width: 100%;
}
}
<div class="section">
<div class="column">
<h1>Column 1</h1>
<p>This is Coulmn 1 with 50% width and float left.</p>
</div>
<div class="column">
<h1>Column 2</h1>
<p>This is Coulmn 2 with 50% width and float left.</p>
</div>
</div>
I would be very thankful if anybody can help me in this!!
I tried applying a background color in whole section using CSS but it is not getting applied.