Reputation: 13
I want to make the width of a div (divTwo) inside of another div (divOne) 100% width despite the 80% width of divOne. Is this possible?
JSFiddle: https://jsfiddle.net/u3mbjgp3/
HTML:
<div class="divOne">
<div class="divTwo"></div>
</div>
CSS:
.divOne {
width: 80%;
height: 250px;
background: #00ff00; /*green*/
}
.divTwo {
width: 100%;
height: 150px;
background: #000; /*black*/
}
Upvotes: 1
Views: 657
Reputation: 122027
If you want divTwo
to take 100% of window width you can use 100vw
body,
html {
margin: 0;
height: 0;
}
.divOne {
width: 80%;
height: 250px;
background: #00ff00;
}
.divTwo {
width: 100vw;
height: 150px;
background: #000;
}
<div class="divOne">
<div class="divTwo"></div>
</div>
Upvotes: 5