float(left、right、none、inherit继承) 让块元素展现在同一行bash
clear(left、right、both、none、inherit) 元素的某个方向上不能有浮动元素spa
clear:both; 在左右两侧均不容许浮动元素code
方法:继承
<style>
.clearfix{
*zoom:1;
}
.clearfix:after{
content:"xxxxx"
display: block;
clear: both;
}
</style>
</head>
<body>
<div class="clearfix"></div>
</body>
复制代码
overflow:hidden(隐藏) scroll(滚动)ci
top、right、bottom、left 定位元素偏移量文档
.div{
position: relative;
left: 200px;
top: 200px
}
复制代码
.div{
position: absolute;
left: 200px;
top: 200px
}
复制代码
<style>
body{
height: 3000px;
}
div{
width: 100px;
height:100px;
background-color: red;
position: fixed;
right:0;
bottom: 0
}
</style>
<body>
<div>返回顶部</div>
</body>
复制代码
position: static; 默认值string
position: inherit; 从父元素继承定位属性的值(不兼容)it
opacity: 0~1(范围);io
IE 6/7 下的透明度设置:filter: alpha(opacity=0~100)table
<style>
div{
width: 100px;
height:100px;
background-color: red;
color: green;
font-size: 20xp;
opacity: 0.5;
}
</style>
<body>
<div>xxxx</div>
</body>
复制代码
z-index:数字; 定位层级
弹层作法
<style>
div{
width: 300px;
height:300px;
}
.box{
margin: 100px;
position: relative;
}
.content{
position: absolute;
background-color: blue;
left: -6px;
top: -6px;
z-index:2;
}
.mark{
position: absolute;
background-color: black;
right: -6px;
bottom: -6px;
z-index: 1;
opacity: 0.5;
}
</style>
<body>
<div class="box">
<div class="content"></div>
<div class="mark"></div>
</div>
</body>
复制代码
border-collapse: collapse; 单元格 间隙 合并
table{
border-collapse: collapse; 单元格*间隙*合并
}
th,td{
padding: 0; 重置单元格默认填充
}
复制代码
<style>
table{
border-collapse: collapse;
}
th,td{
padding: 0;
}
</style>
<body>
<table border="1px">
<thead>
<tr>
<th>星期一</th>
<th>星期二</th>
<th>星期三</th>
<th>星期四</th>
<th>星期五</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</body>
复制代码