I have 3 divs inside a div wrapper.
Div 1 is set to float:left, Div 3 to float:right.
How can I force Div 2 to take up all the space left, be centered and that all 3 are still in one row?
If i try margin: 0 auto; or overflow: hidden; Div 3 doesn't stay in the same row.
.div_wrapper {
width: 600px;
}
.div_1{
float: left;
}
.div_2 {
margin: 0 auto; NOT WORKING
overflow: hidden; NOT WORKING
}
.div_3 {
width: 60px;
float: right;
}
If you float all three to the left and set their widths to 33.33333%.
The trick to your problem is with the order of your <div> elements, and setting overflow:auto on the parent. The <div> is a block-level element by default, so you don't need to do anything special for it to try to use all available width.
Notice the order of the children: 1, 3, 2
<style>
.div_wrapper {width: 600px; overflow:auto;}
.div_1 {width:60px; float:left;}
.div_2 {}
.div_3 {width:60px; float:right;}
</style>
<div class="div_wrapper">
<div class="div_1">Morbi mollis iaculis egestas. Nullam quis nisi at lorem laoreet congue non sollicitudin ante.</div>
<div class="div_3">Pellentesque sodales, justo eget iaculis egestas, nulla lectus consectetur est, pharetra rhoncus purus tortor vel mauris. </div>
<div class="div_2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent id justo quis purus suscipit finibus nec eu augue. Suspendisse sollicitudin rhoncus risus, sit amet consequat velit suscipit non. Vivamus faucibus faucibus nisl eu gravida. Etiam id ipsum non lorem semper tincidunt. Suspendisse potenti. Quisque massa orci, venenatis at purus sed, maximus ullamcorper sem. Cras non sollicitudin quam, ut iaculis felis. Donec rhoncus nisi quis sapien imperdiet tincidunt nec et massa. Mauris felis leo, viverra in consectetur quis, malesuada non neque. Cras at magna massa. Cras non tellus vel ex euismod blandit et non dolor. Nullam at ex nisi. Integer feugiat congue euismod. Quisque consequat urna eget ligula finibus pellentesque.</div>
</div>
You can simply use another wrapper inside the first wrapper with the max width of 540px, if 600px is the max width which is also floated to the left. And inside the inner_wrapper it you can simply assign them again a % width.
HTML:
<div class="div_wrapper">
<div class="div_inner_wrapper">
<div class="div_1_2 div_1"></div>
<div class="div_1_2 div_2"></div>
</div>
<div class="div_1_2_3 div_3"></div>
</div>
CSS:
.div_wrapper {
width: 600px;
}
.div_inner_wrapper {
float: left;
width: 540px;
}
.div_1_2 {
float: left;
width:50%;
}
.div_1 {
height: 30px; // only here for displaying the div
background-color: green; // only here for displaying the div
}
.div_2 {
height: 30px; // only here for displaying the div
background-color: yellow; // only here for displaying the div
}
.div_3 {
float:left;
width:60px;
height: 30px; // only here for displaying the div
background-color: red; // only here for displaying the div
}
Example
Related
Ok, CSS gurus. Here's an easy one for you. I want to have a sidebar to the left of my main content area. I'd like the sidebar to take up 30% of the screen and the content to take up 70%. However, I'd like the sidebar area to take up 100% of the available height. I have
<div id="main">
<div id="side">
<%= render "layouts/sidebar" %>
</div>
<div id="contentArea"><%= yield %></div>
</div>
I thought setting the parent DIV to have "display:flex;" would make everything right ...
#main {
display: flex;
width: 100%;
background-color: green;
}
#side {
background-color: #e0e0e0;
width: 30%;
display: inline-block;
float: left;
height: 100%;
}
#contentArea {
text-align: center;
width: 70%;
display: inline-block;
}
but right now, the height of my sidebar is only equal to the content that's in it. How do I make it 100% of everything?
In your structure ‘main’ is parent div, that’s mean if you set ‘100% of everything’ to child div ‘side’ and this div not position absolute or fixed, ‘main’ get 100% too.
So, you can use relative lengths, like height: 100vh.
jsfiddle
But you can set to side div position fixed: it will help when you get scroll in contentArea, but side div all time will in left side with height 100vh.
jsfiddle
Tip: if you use flex, you can manipulate without float (e.g. justify-content
). Check it: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
The problem is that you specified a height of 100% on #side. Ironically, this actually prevents the column from taking up the full vertical space, as it caps to at the height of the container. Because #main doesn't have a specified height, setting height: 100% on #side will constrain it to the height of the content (text) within.
Simply removing this causes the column to expand to take up the full vertical space:
#main {
display: flex;
width: 100%;
background-color: green;
}
#side {
background-color: #e0e0e0;
width: 30%;
display: inline-block;
float: left;
/*height: 100%;*/
}
#contentArea {
text-align: center;
width: 70%;
display: inline-block;
}
<div id="main">
<div id="side">
Side
</div>
<div id="contentArea">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut interdum quam. Integer nec tincidunt erat, in scelerisque turpis. Pellentesque interdum turpis eu ante gravida, a auctor lacus pulvinar. Maecenas elementum massa ac felis gravida lobortis
vitae eget nisi. Donec erat turpis, condimentum et ipsum in, tincidunt fringilla quam. Nam est dui, porttitor eget nisl sit amet, mollis varius dui. Suspendisse dui mauris, tincidunt vitae blandit ac, consectetur sed ex. Sed bibendum felis ex, id
euismod odio euismod ac. Praesent viverra arcu quis arcu condimentum, eget varius elit suscipit. Donec tempus, justo vel iaculis vehicula, risus magna varius ex, vitae mattis elit turpis ac magna. Fusce porta tempus erat vel ultricies. Suspendisse
vel erat blandit, semper dui sed, consequat urna. Pellentesque ultrices pellentesque feugiat. Donec sit amet turpis in orci accumsan blandit. In tincidunt erat sed tristique sagittis. Duis ultrices lacus quis vestibulum venenatis. Maecenas et risus
quam. Quisque semper purus id mauris gravida dictum. Cras tellus augue, sollicitudin ac maximus eget, porta elementum elit. Fusce vulputate consectetur dapibus. Praesent semper augue lacus, vel laoreet tellus ultricies fermentum. Phasellus vestibulum
fringilla purus ut malesuada.
</div>
</div>
Hope this helps! :)
Use: #side{height: 100vh;} (vh = viewport height), and remove display flex so you can have unequal height for each div.
Link to jsfiddle https://jsfiddle.net/gcoh62o6/5/
This question already has answers here:
Why don't flex items shrink past content size?
(5 answers)
Closed 5 years ago.
I have some content in a nested column whose parent is a nested flex container:
body,
html,
.container {
height: 100%;
}
body {
color: #fff;
}
.container {
display: flex;
overflow: hidden;
}
.sidebar {
width: 200px;
flex-shrink: 0;
background: red;
}
.main {
flex: 1;
display: flex;
}
.content {
flex: 1;
background: blue;
}
.scroll {
overflow-x: auto;
}
.overflowing {
width: 1024px;
}
.panel {
width: 100px;
flex-shrink: 0;
background: green;
}
<div class="container">
<div class="sidebar"></div>
<div class="main">
<div class="content">
<div class="scroll">
<div class="overflowing">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce non lorem blandit, aliquet augue in, egestas risus. Curabitur sit amet justo eget metus faucibus sodales. Vestibulum rhoncus vel libero id imperdiet. Quisque ante quam, tempus in metus a, aliquam sollicitudin tortor. Nam in sagittis nunc, et feugiat augue. Phasellus augue lacus, maximus et ipsum ac, placerat tincidunt risus. Curabitur velit diam, fermentum ac quam eget, ultricies elementum ipsum. Nullam justo dolor, consequat porttitor semper a, eleifend vitae ante. Phasellus egestas dolor sed erat dapibus, a scelerisque dui sagittis. Pellentesque eget venenatis nisi. Vestibulum neque nisl, cursus ut sagittis a, ultrices ac nunc. Etiam auctor nunc porta leo fermentum, a iaculis leo vestibulum. Donec lobortis, tellus a aliquet malesuada, ipsum elit sagittis lectus, sed mollis magna diam eu mauris. Vivamus semper nunc eget nunc lacinia pharetra.</div>
</div>
</div>
<div class="panel"></div>
</div>
</div>
The content has to be fixed-width (for whatever reason). On narrower viewports (like the one in the preview above) it's wider than its container, so I want it to scroll horizontally. I thought it would be as easy as wrapping it in a <div> with overflow-x: auto, but for some reason the content is pushing the right panel off-screen (you can see the panel if you view the result in full-screen).
This seems to happen only if the flex container is nested and the content's width is fixed. How can I prevent the panel from being pushed away?
Updated Answer
The original answer to this question is unnecessarily complex.
The simple truth is that flex items, by default, are min-width: auto. This means they cannot shrink below the size of their content.
That's why a horizontal scroll bar doesn't render in the blue text element. The content is unable to overflow because the item is always expanding to accommodate its content.
The solution is to override min-width: auto with min-width: 0.
.main {
min-width: 0; /* NEW */
}
.content {
min-width: 0; /* NEW */
}
jsFiddle demo
More details here: Why doesn't flex item shrink past content size?
Original Answer
The problem you're describing in your question doesn't exist in Chrome 47 or IE11. The code preview, whether small or full-screen, shows all three panels and horizontal scroll. It does what you want.
In Firefox and Chrome 48, however, there's clearly a problem. There's no horizontal scroll, and the right panel (green), is pushed off screen in the small preview.
These are bugs in Firefox and Chrome 48.
Here's the fix:
To enable a horizontal scrollbar in flexbox in FF/Chrome 48 add min-width: 0; to the parent(s) of the scrolling items.
(optional) To enable a vertical scrollbar add min-height: 0.
The above is a cross-browser solution; it doesn't appear to have any effect on non-buggy browsers. Hence, adding both min-width: 0 and min-height: 0 to your production code should be okay.
body,
html,
.container {
height: 100%;
}
body {
color: #fff;
}
.container {
display: flex;
overflow: hidden;
}
.sidebar {
width: 200px;
flex-shrink: 0;
background: red;
}
.main {
flex: 1;
display: flex;
min-width: 0; /* NEW */
}
.content {
flex: 1;
background: blue;
min-width: 0; /* NEW */
}
.scroll {
overflow-x: auto;
}
.overflowing {
width: 1024px;
}
.panel {
width: 100px;
flex-shrink: 0;
background: green;
}
<div class="container">
<div class="sidebar"></div>
<div class="main">
<div class="content">
<div class="scroll">
<div class="overflowing">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce non lorem blandit, aliquet augue in, egestas risus. Curabitur sit amet justo eget metus faucibus sodales. Vestibulum rhoncus vel libero id imperdiet. Quisque ante quam, tempus in metus a, aliquam sollicitudin tortor. Nam in sagittis nunc, et feugiat augue. Phasellus augue lacus, maximus et ipsum ac, placerat tincidunt risus. Curabitur velit diam, fermentum ac quam eget, ultricies elementum ipsum. Nullam justo dolor, consequat porttitor semper a, eleifend vitae ante. Phasellus egestas dolor sed erat dapibus, a scelerisque dui sagittis. Pellentesque eget venenatis nisi. Vestibulum neque nisl, cursus ut sagittis a, ultrices ac nunc. Etiam auctor nunc porta leo fermentum, a iaculis leo vestibulum. Donec lobortis, tellus a aliquet malesuada, ipsum elit sagittis lectus, sed mollis magna diam eu mauris. Vivamus semper nunc eget nunc lacinia pharetra.</div>
</div>
</div>
<div class="panel"></div>
</div>
</div>
Bug reports:
https://bugzilla.mozilla.org/show_bug.cgi?id=1043520
https://github.com/angular/material/issues/6841
https://code.google.com/p/chromium/issues/detail?id=580196
If I have two div elements. Both have similar parent location and float:right the style attribute. Which one will be more right than the other? I'd like to be able to tell that div1 should be most right, and div2 follows the div1. Or other way around, but this order must be deterministic.
thanks.
UPD: I'd like not to rely on the order of the divs in the html page. My html page gots generated from java/jsp, so i cannot be absolutely sure which div will be generated and written first. Is there another solution?
According to the CSS specification, the first floated element that appears in the code will be placed to the right, followed by the second one.
If there is not enough room on the line, then the second floated element will appear below the first one.
Reference: http://www.w3.org/TR/CSS21/visuren.html#floats
Also, be aware of block-formatting contexts:
http://www.w3.org/TR/CSS21/visuren.html#block-formatting
p {
overflow: auto; /* this creates a block formatting context */
}
img {
float: right;
}
<p>
<img src="http://placehold.it/100x100">
<img src="http://placehold.it/100x200">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer facilisis velit ut neque tempor quis cursus tortor suscipit. Curabitur rutrum magna vitae arcu pharetra eget cursus ante accumsan. Nunc commodo malesuada adipiscing. Pellentesque consequat laoreet sagittis. Sed sit amet erat augue. Morbi consectetur, elit quis iaculis cursus, mauris nulla hendrerit augue, ut faucibus elit sapien vitae justo. In a ipsum malesuada nulla rutrum luctus. Donec a enim sapien. Sed ultrices ligula ac neque vulputate luctus. Suspendisse pretium pretium felis, in aliquet risus fringilla at. Nunc cursus sagittis commodo.</p>
<p>
<img src="http://placehold.it/700x100">
<img src="http://placehold.it/100x200">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer facilisis velit ut neque tempor quis cursus tortor suscipit. Curabitur rutrum magna vitae arcu pharetra eget cursus ante accumsan. Nunc commodo malesuada adipiscing. Pellentesque consequat laoreet sagittis. Sed sit amet erat augue. Morbi consectetur, elit quis iaculis cursus, mauris nulla hendrerit augue, ut faucibus elit sapien vitae justo. In a ipsum malesuada nulla rutrum luctus. Donec a enim sapien. Sed ultrices ligula ac neque vulputate luctus. Suspendisse pretium pretium felis, in aliquet risus fringilla at. Nunc cursus sagittis commodo.</p>
.right {
background: green;
}
.right-too {
background: red;
}
div {
float: right;
height: 20px;
width: 100px;
}
<div class="right">RIGHT</div>
<div class="right-too">RIGHT TOO</div>
The one to appear first in the code will be further on the right.
Edit: added a snippet
First one is more right..
<div style='width: 600px; height: 200px; border: 1px solid black;'>
<div style='width: 200px; height: 100px; background-color: yellow; float: right;'>A</div>
<div style='width: 200px; height: 100px; background-color: green; float: right;'>B</div>
</div>
Here is the jsfiddle: http://jsfiddle.net/q6wnm4dv/
The first one you write in the HTML will be the first one from the right side.
HTML:
<div class="wrapper">
<div class="div1"></div>
<div class="div2"></div>
</div>
CSS:
.wrapper {
width: 100%;
height: 50px;
}
.div1 {
float: right;
background-color: red;
height: 50px;
width: 50px;
}
.div2 {
float: right;
background-color: blue;
height: 50px;
width: 50px;
}
Here you can see the working example: https://jsfiddle.net/mgjdjf62/
the best way to order items is to use flexbox: a guide to flexbox
I am trying to get my main content and menu divs to stretch to the top of the footer div. My HTML is:
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
#wrapper {
min-height: 100%;
position: relative;
}
#header {
padding: 10px;
background: #3095C7;
}
#main {
padding-bottom: 80px;
bull
}
#content {
padding-left: 310px;
background: #FFEFC4;
}
#menu {
background: #67b5d1;
width: 300px;
position: absolute;
float: left;
}
#footer {
text-align: center;
padding: 30px 0;
width: 100%;
height: 50px;
position: absolute;
bottom: 0;
left: 0;
background: #3095C7;
}
<div id="wrapper">
<div id="header"></div>
<div id="main">
<div id="menu">
menu here
</div>
<div id="content">
content here
</div>
</div>
<div id="footer">footer content</div>
</div>
I have set the main, content, and menu height to 100%, but that of course just is to the very bottom of the wrapper div, which is beyond footer. What I am trying for is for menu and content to stretch from the header all the way down to the top of footer, so it fills the whole page. I have played around with vh but isn't spot on constantly when re-sizing the window.
Are there any tricks that will make the divs fill all the blank space and not overlap the footer?
Very simple with flexbox (browser support is IE10+ and everything else that's remotely modern)
Set up #wrapper to be display: flex; flex-flow: column nowrap
Set up #main to be flex: 1 1 auto and display: flex so 1) that it grows to the necessary height and 2) so that it's children will also grow to the height of #main.
Set flex: 0 1 300px on #menu (and remove floats/position: absolute) and set #content to be flex: 1 1 auto.
EDIT
Forgot to remove position: absolute (and associated bottom/left rules) from the footer. I also added a ton of content (and modified the left menu to not shrink flex: 0 0 300px instead of flex: 0 1 300px so that a bunch of content doesn't collapse it into nothing-ness
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
#wrapper {
min-height: 100%;
display:flex;
flex-flow: column nowrap
}
#header {
padding: 10px;
background: #3095C7;
}
#main {
display: flex;
flex: 1 1 auto;
}
#content {
flex: 1 1 auto;
background: #FFEFC4;
}
#menu {
background: #67b5d1;
flex: 0 0 300px;
}
#footer {
text-align: center;
padding: 30px 0;
width: 100%;
height: 50px;
background: #3095C7;
}
<div id="wrapper">
<div id="header"></div>
<div id="main">
<div id="menu">
menu here
</div>
<div id="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eu tristique ex, at rhoncus sem. Interdum et malesuada fames ac ante ipsum primis in faucibus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec non ipsum ut nulla volutpat gravida. Donec euismod nibh venenatis fermentum dignissim. Nulla sagittis tristique felis vitae fermentum. Phasellus at viverra sem. In scelerisque mi ac dolor convallis, vitae convallis felis condimentum. Donec porta leo nec semper luctus. In dignissim bibendum viverra. Maecenas molestie, dui eget finibus hendrerit, arcu turpis dapibus arcu, laoreet aliquam lectus justo a lorem. In et enim ac elit tincidunt imperdiet. Phasellus eget erat sed nulla placerat venenatis et in ligula. Mauris volutpat feugiat diam sit amet bibendum. Donec vulputate tristique augue vel pharetra. Mauris orci quam, pharetra lacinia commodo eu, tristique at est.
Morbi metus sapien, venenatis a pulvinar eget, accumsan et nisi. Phasellus vitae blandit augue. Proin quis mollis orci. Ut consequat tempor nulla id dignissim. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce in euismod nibh, pharetra laoreet eros. Donec feugiat neque est, ac pharetra quam sollicitudin a.
Donec hendrerit ac magna at tincidunt. Pellentesque eget eros vel mauris porttitor aliquam ac vel tortor. Vestibulum vitae porttitor enim, eu scelerisque quam. Suspendisse tincidunt nisi non eros condimentum, quis faucibus arcu pellentesque. Morbi aliquet, est at pretium molestie, est arcu volutpat lectus, et condimentum leo risus sed velit. Maecenas at fermentum magna. Duis sit amet pretium ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum diam est, facilisis eu tellus vel, sagittis pretium metus. Aenean fermentum sem eu finibus dignissim. Fusce lacinia purus at libero ornare ultricies. Etiam pellentesque erat nisi, a ullamcorper arcu varius eu. Quisque lacinia bibendum ipsum vitae bibendum.
Maecenas non consequat augue, id euismod magna. Vestibulum ut maximus eros, ut efficitur neque. Aenean feugiat nunc et viverra pulvinar. Praesent vitae lobortis mi. Duis eu lorem a velit consequat fringilla at eu lacus. Ut mi mauris, cursus et lectus non, auctor iaculis eros. Sed sit amet efficitur arcu. Maecenas in enim quis massa vestibulum imperdiet ac quis dui. Curabitur malesuada, neque eu scelerisque sagittis, erat nisl condimentum sapien, vitae volutpat felis nisi ac lectus. Fusce iaculis mollis enim, vitae consectetur metus egestas sed. Proin lacus lorem, finibus ut tincidunt quis, tincidunt a urna. Donec fringilla risus augue, et bibendum diam cursus vitae. Aenean mattis sapien eget volutpat ornare.
</div>
</div>
<div id="footer">footer content</div>
</div>
I think your code is a bit messed.
If I understood correctly your question you have a header and footer with fixed height and you want the content of the web to fill the height of the (vertical) window.
When using height:100% remember all parents need to have same height 100% but then you may have a problem as height 100% plus the fixed height of footer and header will create a scroll bar.
you can use css calc to substract px's to 100% height. I calculate the pixels you need to subtract in your example and the height for your content shoudl be:
height:calc(100% - 110px);
AND the height of your main:
height:calc(100% - 20px);
The rest is your css's with many changes to achieve what I think you were looking for. corrent me if I am wrong: FIDDLE
(you can see I also used calc to set the width to your content since your menu also had fixed width)
Note: carefull with the use of this technique if you NOT using border-boxfor your containers as all the paddings you are using add width (or height) to your elements. I recomend you to get use to add
* {
box-sizing: border-box;
}
in your css sheets. Once you get use to your live will be easier (just my humble opinion, some may disagree)
Assuming your footer has a fixed height, you can automatically set the height of #menu and #content using position: absolute:
position: absolute;
top: 0;
bottom: 110px; /* #footer height */
Most of the time, absolutely positioned elements have auto values of height and width computed to fit the contents of the element. However, non-replaced absolutely positioned elements can be made to fill the available space by specifying (as other than auto) both top and bottom and leaving height unspecified (that is, auto). Likewise for left, right, and width.
See: https://developer.mozilla.org/en-US/docs/Web/CSS/position#Notes
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
#wrapper {
min-height: 100%;
position: relative;
}
#header {
padding: 10px;
background: #3095C7;
}
#main {
position: absolute;
top: 20px;
bottom: 0;
width: 100%;
}
#content {
position: absolute;
left: 310px;
right: 0;
top: 0;
bottom: 50px;
background: #FFEFC4;
}
#menu {
background: #67b5d1;
top: 0;
bottom: 50px;
width: 300px;
position: absolute;
}
#footer {
text-align: center;
padding: 30px 0;
width: 100%;
height: 50px;
position: absolute;
bottom: 0;
left: 0;
background: #3095C7;
}
<div id="wrapper">
<div id="header"></div>
<div id="main">
<div id="menu">
menu here
</div>
<div id="content">
content here
</div>
</div>
<div id="footer">footer content</div>
</div>
Add a specified height into your CSS, e.g. height: 100px and then set overflow to hidden.
So basically, just add:
height: 100px;
overflow: hidden;
to your menu and content.
I expect my question has already been answered numerous times but I couldn't find it.
I'm trying to create 2 divs which are next to each other within a container. However as soon as I add content, they overflow. I've included a JSFiddle but for some reason my 2 divs are already appearing outside of the container - it doesn't on my local version. I'd like the div which the content is in to expand as well as the container. Hope I've explained it ok.
JSFiddle
* {
margin:0px;
padding:0px;
}
body {
background-color:#C0D498;
}
#page-wrap {
background-color:#FFF;
width:940px;
margin:0 auto;
margin-top: 40px;
border-radius: 5px;
padding: 20px;
}
.logo {
width:175px;
height:auto;
}
.banner {
width:755px;
height:175px;
float:right;
border-radius: 5px;
background-image:url('images/banner.png');
}
.contentWrap {
padding-bottom: 20px;
}
.contentMain {
width:70%;
background-color:blue;
float:left;
}
.contentSub {
width:30%;
background-color:red;
float:left;
}
replace your html with this:
<div id="page-wrap">
<div class="banner"></div>
<div class="contentWrap">
<div class="contentMain">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ac semper mauris. Maecenas orci dui, auctor ac auctor eu, pretium et mi. Donec interdum diam in est euismod gravida. Curabitur ligula tortor, bibendum nec odio maximus, efficitur lobortis mauris. Vestibulum in est rutrum, imperdiet turpis quis, elementum massa. Sed quis odio ut urna porttitor lobortis. Vivamus feugiat accumsan porttitor. Quisque sed ligula ac neque faucibus tristique. Suspendisse molestie eleifend purus vitae maximus. Proin posuere ante ut velit condimentum aliquam. Nullam pellentesque, mi rhoncus sagittis efficitur, libero ante scelerisque turpis, quis cursus dui libero eget dui. Suspendisse fringilla ut massa at aliquam. Praesent ut tempus erat, nec euismod ligula. Aliquam dui ex, viverra id commodo a, cursus sed sem. Praesent vel egestas nisl.</div>
<div class="contentSub">g</div>
</div>
<div style="clear:both; float:none;"></div>
</div>
The important part is this: <div style="clear:both; float:none;"></div>
and of course you can do it like this (recommended)
<div class="clear"></div>
and CSS
.clear{clear:both; float:none;}
.contentWrap { overflow: hidden; }
only this!
don't know if you want to float your banner
http://jsfiddle.net/flocko/fhrpghjb/
.contentWrap {
padding-bottom: 20px;
clear: both;
overflow: hidden;
}
as a rule of thumb: every element you float - you should clear in the parent element.
a clearfix class could help you on your way: http://nicolasgallagher.com/micro-clearfix-hack/