Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

100% Screen width on div nested in fixed width div css

Tags:

html

css

I'm trying to get a nested div to be full width on screen out of the div that it's contained/nested in.

http://jsfiddle.net/TheeAndre/JAdps/

<div class="fixedwidth">
    <div class="fullwidth"></div>
</div>
like image 250
imbayago Avatar asked Sep 28 '13 05:09

imbayago


2 Answers

Try

width:100vw;  

instead of

width:100%;  

Check for compatibility issues: http://caniuse.com/#search=vw

Pascalz, yes in your jsfiddle it works, but only as long as you don't specify a position other than static for your parent. In many cases you need your parent to be position:relative, so the child will relate width:100% to parent width.

like image 106
Jan Mirus Avatar answered Sep 18 '22 18:09

Jan Mirus


try this :

.fullwidth {
    background-color:#000; 
    width:100%; 
    height:100px; 
    position:absolute; 
    z-index:999;
    left: 0;
    right: 0;
}
like image 45
Pascalz Avatar answered Sep 18 '22 18:09

Pascalz