css - How to stretch the background color of a child element so that it has the same height as the parent element while using float? -
please java guy simple css problem. been trying hours , can't find proper solution problem: how stretch background color of child element has same height parent element while using float? bet has display:flex, can't work :-/
here's code: https://jsfiddle.net/bycor29w/
goal: right column background colour must filled same height middle column no matter how or little text contains
requirement: must use float
stackoverflow demands: "links jsfiddle.net must accompanied code", here go:
<!doctype html> <html> <head lang="en"> <meta charset="utf-8"> <title></title> </head> <body> <style> div { border: 1px #000 solid; } .container { height: 100%; width:980px; float:left; display: flex; } .left { width: 200px; float: left; } .mid{ padding-top: 1px; width: 560px; float: left; } .right { background: #d8d8d8 repeat-y bottom right; padding: 0 20px; height:100%; align-self: center; flex: 1; width: 180px; float: left; } </style> <div class="container"> <div class="left"> asdf<br> asdf<br> asdf<br> </div> <div class="mid"> asdf<br> asdf<br> asdf<br> asdf<br> asdf<br> asdf<br> </div> <div class="right"> asdf </div> </div> </body> </html>
firstly, flexbox override floats...if want use floats...don't use flexbox.
what seem want can achieved using css tables....you can still use floats if absolutely necessary.
* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } div { border: 1px #000 solid; } .container { width: 580px; display: table; overflow: auto; vertical-align: top; } .left { width: 100px; float: left; display: table-cell; vertical-align: top; } .mid { padding-top: 1px; width: 370px; float: left; display: table-cell; vertical-align: top; } .right { background: lightblue; width: 100px; display: table-cell; vertical-align: top; } <body> <div class="container"> <div class="left"> asdf <br>asdf <br>asdf <br> </div> <div class="mid"> asdf <br>asdf <br>asdf <br>asdf <br>asdf <br>asdf <br> </div> <div class="right"> asdf </div> </div> </body>
Comments
Post a Comment