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>
複製代碼