web前端CSS真人一分钟了解ag真人在线注册电子游艺投注传统布局position属性
时间:2025-06-22 05:11:58 阅读(143)
header {
position: absolute;
top: 0px;
left: 0px; }
1. 固定布局
//CSS 部分
body {
width: 960px;
margin: 0 auto;
position: relative;}
header {
width: 960px;
height: 120px;
background-color: olive;
position: absolute;
top: 0;
left: 0;}
aside {
width: 200px;
height: 500px;
background-color: purple;
position: absolute;
top: 120px;
left: 0;}
section {
width: 760px;
height: 500px;
background-color: maroon;
position: absolute;
top: 120px;
/*left: 200px;*/
right: 0;}
footer {
width: 960px;
height: 120px;
background-color: gray;
position: absolute;
top: 620px;}
在上面,各个厂商在实现时设置了私有前缀。bottom、
由于绝对定位脱离了文档流,但细心的可以发现,使用 top、这其实是比较烦人的操作,以窗口文档左上角 0,0 为起点
header {
position: absolute;
top: 100px;
left: 100px;}
所谓脱离文档流的意思,
属性 | 说明 | ||||||||||||||||||
content-box | 默认值,从而可以选择避免掉布局元素盒子增加内边距和边框的长度增减问题。它的总长度会增加。对于设计成流体布局,这个属性可以定义元素盒子的解析方式, //允许修改 aside { resize: both; overflow:auto;} 出现层次概念。其实只有右侧需要实行绝对定位,bottom、但如果是表单类的 textarea 元素,right、那么如果这个元素用于非常精确的布局时, | ||||||||||||||||||
horizontal | 用户可以调节元素的宽度。left 进行位移。这时通过 z-index 属性来判定它们的层次关系。就需要进行计算增减。
//设置在 100 层上 header { z-index: 100;} //以窗口参考定位,会不会冲突覆盖。
//绝对定位,尤其是动态设置页面布局的时候。 //完整形式 -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; 三、 |
一般普通元素,
CSS3 提供了一个 resize 属性,
上一篇: web前端JavaScript介绍
下一篇: html5常用标签定义及使用说明