Rumah >hujung hadapan web >html tutorial >左右两边高度自适应,右边宽度为浏览器宽度-200px。这个是怎么理解的呀?_html/css_WEB-ITnose
<!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>初试试题</title><style>body { margin:0px 0px; padding:0px 0px; color:#fff; text-align:center;}#header { background:#0175ed; height:120px; line-height:120px;}#header, #footer, #container { margin: 0px auto; width: 100%;}#contentWrap { margin-left: -200px; float:right; width: 100%; background:#86aef7}#content { margin-left: 200px;}#side { float:left; width: 200px; background:#55a3f3;}#contentWrap,#side{ min-height: 500px; height: auto !important; height: 500px;}#footer { clear: both; background:#0175ed; height:50px; line-height:50px;}</style></head><body><div id="container"><div id="header">高度120px</div><div id="main"><div id="contentWrap"><div id="content">右边宽度100%-200px</div></div><div id="side">左边宽度200px</div></div><div id="footer">底部高度50px</div></div></body></html>
width:100%
position: abusote;
left : 0px;
用padding-left:200px; 来占位吧
这样做可以实现以上所说布局
<!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>初试试题</title><style>body { margin:0px 0px; padding:0px 0px; color:#fff; text-align:center;}#header { background:#0175ed; height:120px; line-height:120px;}#header, #footer, #container { margin: 0px auto; width: 100%;}#right,#side{ min-height: 500px; height: auto !important; height: 500px;}#side { float:left; width: 200px; background:#55a3f3;}#right { background:#86aef7}#footer { clear: both; background:#0175ed; height:50px; line-height:50px;}</style></head><body><div id="container"> <div id="header">高度120px</div> <div id="main"> <div id="side">左边宽度200px</div> <div id="right">右边宽度100%-200px</div> </div> <div id="footer">底部高度50px</div></div></body></html>
这样做可以实现以上所说布局
<!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>初试试题</title><style>body { margin:0px 0px; padding:0px 0px; color:#fff; text-align:center;}#header { background:#0175ed; height:120px; line-height:120px;}#header, #footer, #container { margin: 0px auto; width: 100%;}#right,#side{ min-height: 500px; height: auto !important; height: 500px;}#side { float:left; width: 200px; background:#55a3f3;}#right { background:#86aef7}#footer { clear: both; background:#0175ed; height:50px; line-height:50px;}</style></head><body><div id="container"> <div id="header">高度120px</div> <div id="main"> <div id="side">左边宽度200px</div> <div id="right">右边宽度100%-200px</div> </div> <div id="footer">底部高度50px</div></div></body></html>是可以实现,但是,我想知道右边的宽度计算。你这个写法不对吧~~~