This nested div
renders differently in FireFox and Chrome. Chrome, with the result I am looking for.
A div
that can grow with content, inside of another div
that has a padding of 20px
.
The effect should look like it has a 20px
bar above and below the nested div
like this (in Chrome).
http://jsfiddle.net/SEOplay/58xRJ/2/embedded/result/
The code I'm using:
HTML
<section>
<div class="dualContainer">
<div class="dualBgBlock"></div>
<div class="dualMiddle">
<div class="dualContent"></div>
</div>
</div>
</section>
CSS
div.dualContainer {
margin-top:50px;
margin-bottom:20px;
position:relative;
z-index:0;
width:100%;
}
div.dualBgBlock {
position:absolute;
top:0;
bottom:0;
right:0;
left:0;
margin:auto;
background-color:#ccc;
width:60%;
height:100%;
padding:20px;
}
div.dualMiddle {
width:80%;
margin:0 auto;
}
div.dualContent {
background-color:#333;
overflow:hidden;
position:relative;
height:200px;
}
Link to the fiddle: http://jsfiddle.net/SEOplay/58xRJ/2/
So how can I get FireFox to render my code the way Chrome does?
margin: auto
on the.dualBgBlock
behaves differently. In Chrome, it centers horizontally and vertically, but in Firefox it only centers horizontally (likemargin: 0 auto
). I'm not sure what's going on here, vertical centering in CSS has always been problematic.