html - Extra div causing the image height not scaling properly (display: flex) -
i took code here. code working when added div
wrap div
class fullwidth
, images height not scale equally depending on height of screen.
this how looks originally:
body, html { height: 100%; } .fullwidth { display: flex; flex-direction: column; height: 100%; } .repeat-x { flex: 1; background-size: cover; background-repeat: no-repeat; background-position: center center; } .bg-1 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); } .bg-2 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); } .bg-3 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); }
<div class="fullwidth"> <div class="repeat-x bg-1"> </div> <div class="repeat-x bg-2"> </div> <div class="repeat-x bg-3"> </div> </div>
after wrapping fullwidth
div
:-
body, html { height: 100%; } .fullwidth { display: flex; flex-direction: column; height: 100%; } .repeat-x { flex: 1; background-size: cover; background-repeat: no-repeat; background-position: center center; } .bg-1 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); } .bg-2 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); } .bg-3 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); }
<div id="newid"> <div class="fullwidth"> <div class="repeat-x bg-1"> </div> <div class="repeat-x bg-2"> </div> <div class="repeat-x bg-3"> </div> </div> </div>
add height: 100%
newid
container - allows flexbox
inherit height
of document.
see demo below:
body, html { height: 100%; } #newid { height: 100%; } .fullwidth { display: flex; flex-direction: column; height: 100%; } .repeat-x { flex: 1; background-size: cover; background-repeat: no-repeat; background-position: center center; } .bg-1 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); } .bg-2 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); } .bg-3 { background-image: url(http://oi65.tinypic.com/28v4p6u.jpg); }
<div id="newid"> <div class="fullwidth"> <div class="repeat-x bg-1"> </div> <div class="repeat-x bg-2"> </div> <div class="repeat-x bg-3"> </div> </div> </div>
Comments
Post a Comment