CSS属性书写顺序
1. 布局定位属性
- display/position/float/clear/visibility/overflow(建议display第一个写)
2. 自身属性
- width/height/margin/padding/border/background
3.文本属性
- color/font/text-decoration/text-align/vertical-align/white-space/break-word
4. 其他属性(CSS3)
- content/cursor/border-radius/box-shadow/text-shadow/background:linear-gradient…
<!--样例-->
.jdc {
display:block;
position:relative;
float:left;
width:100px;
height:100px;
margin:0 10px;
padding:20px 0;
font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;
color:#333;
background:rgba(0,0,0,.5);
border-radius:10px;
}
页面布局基本思路
- 测量页面版心(可视区)
- 分析页面行模块和每个行模块中的列模块(第一准则)
- 一行中的列模块经常浮动布局,先确定每个列的大小,再确定位置(第二准则)
- 先写html结构,再写样式
- 理清布局结构
案例
- 实际开发中,导航栏不会直接用链接a而是用li包含链接(li+a)的做法
网页布局总结
- 垂直的块级盒子用标准流布局
- 多个块级盒子水平显示用浮动布局
- 如果元素在某盒子内移动用定位布局