探讨这种布局是因为最近对话框组件以及信息系统B/S界面布局的需要。无论是什么,我们在写CSS之前首先引入reset.css,我使用的是淘宝的reset。句容市鄂茂钢铁
05 |
body, h 1 , h 2 , h 3 , h 4 , h 5 , h 6 , hr, p, blockquote, |
06 |
dl, dt, dd, ul, ol, li, |
08 |
form, fieldset, legend, button, input, textarea, |
15 |
button, input, select, textarea { |
16 |
font : 12px / 1.5 tahoma , arial , \ 5 b 8 b\ 4 f 53 , sans-serif ; |
18 |
h 1 , h 2 , h 3 , h 4 , h 5 , h 6 { font-size : 100% ; } |
19 |
address, cite, dfn, em, var { font-style : normal ; } |
20 |
code , kbd, pre , samp { font-family : courier new, courier , monospace ; } |
21 |
small { font-size : 12px ; } |
23 |
ul, ol { list-style : none ; } |
25 |
a { text-decoration : none ; } |
26 |
a:hover { text-decoration : underline ; } |
27 |
sup { vertical-align : text-top ; } |
28 |
sub { vertical-align : text-bottom ; } |
30 |
legend { color : #000 ; } |
31 |
fieldset, img { border : 0 ; } |
32 |
button, input, select, textarea { font-size : 100% ; } |
35 |
table { border-collapse : collapse ; border-spacing : 0 ; } |
声明DTD:
使用display:inline-block属性
将对象呈递为内联对象,但是对象的内容作为块对象呈递。旁边的内联对象会被呈递在同一行内,允许空格。我们知道在IE6.0以及IE7.0是使用了一个has layout的概念。使用display:inline-block仅仅触发了块状元素的has layout属性。而DIV本身就是块状元素,所以在IE<8.0 下依然会出现换行的情况。
解决问题:先将块元素设置为内联对象呈递(设置属性display:inline),然后触发块元素的layout去hack IE7.0-;
1 |
div{ display :inline- block ;zoom: 1 ;* display : inline ;} |
HTML
2 |
< div class = "subMenuLeft" ></ div > |
3 |
< div class = "mainBoxCenter" > |
5 |
< div class = "infoRight" > |
CSS
05 |
div.subMenuLeft,div.mainBoxCenter,div.infoRight{ |
07 |
zoom: 1 ; * display : inline ; |
使用float负边距的布局
该属性的值指出了对象是否及如何浮动。当该属性不等于none引起对象浮动时,对象将被视作块对象(block-level),即display属性等于block。也就是说,浮动对象的display特性将被忽略。
其实CSS的float属性,作用就是改变块元素(block element)对象的默认显示方式。block对象设置了float属性之后,它将不再独自占据一行。可以浮动到左侧或右侧。
由此我们知道可以设置三个DIV默认全部向左浮动,然后设置后两个DIV的margin属性让其显示到必要的位置。
2 |
< div class = "mainBoxCenter" > |
5 |
< div class = "subMenuLeft" > |
7 |
< div class = "infoRight" > |
- 设置div.content的宽度为100%,充满整个窗口,并向左浮动;
- 设置div.mainBoxCenter的左外边距以及右外边距分别等于要显示的两个DIV的宽度;
- 设置div.subMenuLeft向左浮动,并且margin-left:100%;这样subMenuLeft偏移到屏幕的最左方;
- 设置div.infoRight向左浮动,并且margin-left值为自身的宽度,这样infoRight便偏移到屏幕的右侧。
05 |
div.subMenuLeft,div.infoRight{ |
CSS设计一个三列布局的页面
原文:http://www.cnblogs.com/xiaoyang002/p/4102482.html