div 自适应宽度
2015-02-12 16:54
85 查看
div 自适应宽度
ie6 下 float 元素的空隙 问题:
解决方案:
float:left; 时 _margin-right:-3px;
float:right;时 _margin-left:-3px;
转自:http://kuchaguangjie.iteye.com/blog/752234
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> body {margin: 0 auto;text-align: center;} #container {text-align: left;background-color: green;} #top {height: 160px;background-color: red;} #middle {height: 240px;background-color: yellow;} #middle_left {height:240px;width: 200px;float: left;background-color: #333;} #middle_right {height:240px;width: 220px;float: right;background-color: #ddd;} /* 自适应宽度的 div:1.不要设置 width,即 width:auto ,2.不要设置 float,即 float:none,3.其div的位置应放在最后,比 float='right' 的 div 还靠后*/ #middle_center {height:240px;background-color: #aaa;} #foot {height: 120px;background-color: teal;} .clearDiv {clear:both;} </style> </head> <body> <div id="container"> <div id="top">top</div> <div class="clearDiv"></div> <div id="middle"> <!-- 居左 --> <div id="middle_left">middle left</div> <!-- 居右 --> <div id="middle_right">middle right</div> <!-- 自适应宽度的 div 应放在最后 --> <div id="middle_center">middle center</div> </div> <div class="clearDiv"></div> <div id="foot">foot</div> </div> </body> </html>
ie6 下 float 元素的空隙 问题:
解决方案:
float:left; 时 _margin-right:-3px;
float:right;时 _margin-left:-3px;
转自:http://kuchaguangjie.iteye.com/blog/752234
相关文章推荐
- css+div宽度自适应实例代码
- td里的内容宽度自适应 及 鼠标放上显示标题div title
- 两列布局,左边div固定宽度,右边宽度自适应
- div根据div内文字背景图自适应宽度
- div或img图片高度随宽度自适应
- div宽度自适应
- DIV 自适应宽度 布局
- div 两列布局,左侧固定宽度px,右侧自适应宽度,满屏
- DIV+CSS 布局一行两列,左列固定宽度,右列自适应宽度;设置最小宽度,窗口小的时候显示滚动条.
- 【CSS】三列布局(左右div固定宽度,中间div随浏览器窗口自适应变化宽度)
- html css div自适应屏幕宽度,高度
- div三列,中间一列宽度自适应,2边固定
- 水平自适应居中 宽高固定的div 宽高不知道的div 左右两边固定宽度div
- html css div自适应屏幕宽度,高度
- css实现左边div固定宽度,右边div自适应撑满剩下的宽度
- div自适应宽度方法
- html css div自适应屏幕宽度,高度
- css+div+图片实现宽度自适应圆角框
- css三列布局,中间div固定,两侧div宽度自适应
- 负边距(negative margin)实现自适应的div左右排版(一个宽度固定一个宽度自适应)”