The adaptive height problem is that when three or two columns are laid out using Div + CSS, you do not know the specific height beforehand. You can only increase or decrease the adaptive height based on the content, to make the two (or three) columns have the same height, it is easy to use Table, but it is quite troublesome to use Div + CSS. According to the general practice, most of them use the background image filling or JS script method to make the height the same, but these are not the best methods. I think...
The following describes how to use a combination of "hide container overflow", "positive patch", and "negative Patch".
Main code:
| The code is as follows: |
Copy code |
# Wrap {overflow: hidden;}/* External container */ # Sidebar_left, # sidebar_right {padding-bottom: 100000px; margin-bottom:-100000px;}/* column */
|
Complete example code:
| The code is as follows: |
Copy code |
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/> <Title> Div + CSS Example, Wayhome's Blog </title> <Style type = "text/css"> <! -- # Wrap {overflow: hidden ;} # Sidebar_left, # sidebar_right {padding-bottom: 100000px; margin-bottom:-100000px ;} --> </Style> <Body> <Div id = "wrap" style = "width: 300px; background: # FFFF00;"> <Div id = "sidebar_left" style = "float: left; width: 100px; background: # FF0000;"> Left </div> <Div id = "sidebar_mid" style = "float: left; width: 100px; background: #666;"> Middle <br/> Middle <br/> Middle <br/> Middle <br/> Middle <br/> Middle <br/> Middle <br/> Middle <br/> Middle <br/> </Div> <Div id = "sidebar_right" style = "float: right; width: 100px; background: # 0000FF;"> Right </div> </Div> </Body> </Html>
|