html - Setting a responsive height to a container while vertically centering content -
i'm trying solve issue height of container should responsive when minimizes browser window. content in container should stay veritcally centered too.
here's have far in codepen: http://codepen.io/anon/pen/pnzzoe
the container blue box contains text. blue box should have same height dummy image when adjusting browser window size.
thanks ahead help!
code in codepen:
html
<html> <head> </head> <body> <div class="grid_12 alpha omega" id="llcontentcont"> <!-- row 1 --> <div class="llrow" id="llrow1"> <div class="llcontent"> <div class="grid_4 llfr alpha"> <div class="lltext"> <h3>header</h3> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. nullam hendrerit tristique sem, dictum ornare lectus.</p> </div> </div> <div class="grid_8 omega"> <a href="" title=""><img src="http://dummyimage.com/868x500/00e1ff/000.gif&text=dummy+image" alt=""></a> </div> </div> </div> <!-- /row 1 --> <!-- row 2 --> <div class="llrow" id="llrow2"> <div class="llcontent"> <div class="grid_8 alpha"> <a href="" title=""><img src="http://dummyimage.com/868x500/00e1ff/000.gif&text=dummy+image" alt=""></a> </div> <div class="grid_4 llfl omega"> <div class="lltext"> <h3>header</h3> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. nullam hendrerit tristique sem, dictum ornare lectus.</p> </div> </div> </div> </div> <!-- /row 2 --> </div> </body> </html>
css
body { width: 100%; background: #ccc; } #llcontentcont {width: 100%;} #llcontentcont, .llrow, .grid_4, .grid_8 { float: left; display: inline; position: relative; } .llrow { width: 100%; margin: 10px 0 0; } .llcontent { min-width: 976px; margin: 0 auto; max-width: 1200px; width: 100%; } .llcontent .grid_4 { display: table; height: 100%; background: #0091ff; width: 26%; } .llcontent .grid_8 { height: 100%; width: 72.3%; } .llcontent .grid_8 img { width: 100%; } .lltext { display: table-cell; vertical-align: middle; }
remove other display property , give display: flex;
.llcontent
, .llcontent .grid_4
. , align-items: center;
.llcontent .grid_4
work you.
css:
.llcontent { min-width: 976px; margin: 0 auto; max-width: 1200px; width: 100%; display: flex; } .llcontent .grid_4 { background: #0091ff; width: 26%; display: flex; align-items: center; } .llcontent .grid_8 { width: 72.3%; } .llcontent .grid_8 img { width: 100%; }
Comments
Post a Comment