I am trying to make a three column layout with right/left sidebars and main content.
I am floating the left sidebar to the left and right sidebar to the right hoping for the main content to wrap around the right sidebar as it comes after the right sidebar in the HTML. When all three elements have a width of 25% of the main div
, then the content wraps below the left sidebar div
and doesn't wrap around the right sidebar div
. However, when I increase the width of main
to something like 75%, it seems to be staying in the middle.
.left-sidebar {
background: red;
width: 25%;
float: left;
}
.right-sidebar {
background: blue;
width: 25%;
float: right;
}
.main {
background:yellow;
width: 25%;
}
<body>
<div class="left-sidebar">Lorem ipsum dolor sit amet, </div>
<div class="right-sidebar">Filler</div>
<div class="main">Text</div>
</body>
Can someone please tell me what causes this?