這篇文章主要為大家展示了“CSS語(yǔ)法的常用技巧有哪些”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“CSS語(yǔ)法的常用技巧有哪些”這篇文章吧。
屯昌ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書(shū)銷(xiāo)售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書(shū)合作)期待與您的合作!

盒模型
content-box (W3C 標(biāo)準(zhǔn)盒模型)
border-box (IE 盒模型)
具體區(qū)別是: 1. border-box的寬度一旦確定,就不會(huì)改變。width = border + padding + 內(nèi)容的寬度 2. content-box會(huì)根據(jù)padding增加或者是減小。width = 內(nèi)容的寬度
BFC
就是一個(gè)容器,里外不相互影響,記住:清除浮動(dòng)的時(shí)候,如果使用 overflow: hidden,是存在缺點(diǎn)的,如果超過(guò)了范圍,那么則被隱藏了
觸發(fā)原理
1 根元素 2 float屬性不為none,例如left、right 3 position為absolute或fixed 4 display為inline-block, table-cell, table-caption, flex, inline-flex 5 overflow不為visible,例如hidden、auto
規(guī)則
1. 內(nèi)部的Box會(huì)在垂直方向,一個(gè)接一個(gè)地放置。 2. 屬于同一個(gè)BFC的兩個(gè)相鄰Box的margin會(huì)發(fā)生重疊。 3. BFC的區(qū)域不會(huì)與float box重疊。 4. BFC就是頁(yè)面上的一個(gè)隔離的獨(dú)立容器,容器里面的子元素不會(huì)影響到外面的元素 5. 計(jì)算BFC的高度時(shí),浮動(dòng)元素也參與計(jì)算
作用
1. 清除浮動(dòng),BFC里面的浮動(dòng)元素高度也會(huì)參與計(jì)算 2. 防止margin重疊
清除浮動(dòng)
.clearfix:after{
content: '',
height: 0;
display: block;
visibility: hidden;
clear: both;
line-height:0;//行高為0
}布局
浮動(dòng)布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
.left {
float: left;
width: 300px;
height: 100px;
background-color: red;
}
.right {
float: right;
width: 300px;
height: 100px;
background-color: blue;
}
.center {
margin: 0px 300px 0px 300px;
background-color: black;
height: 100px;
}
</style>
</head>
<body>
<div class="father">
<div class="left">1</div>
<div class="right">2</div>
<div class="center">3</div>
</div>
</body>
</html>缺點(diǎn):會(huì)存在塌陷的問(wèn)題
Flex布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
.father {
display: flex;
}
.left {
width: 300px
height: 100px;
background-color: red;
}
.center {
flex:1;
height: 100px;
background-color: black;
}
.right {
width: 300px;
height: 100px;
background-color: blue;
}
</style>
</head>
<body>
<div class="father">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
</body>
</html>絕對(duì)定位
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
.left {
position: absolute;
left:0px;
left: 300px;
height: 100px;
background-color: red;
}
.right {
position: absolute;
right:0px;
width: 300px;
height: 100px;
background-color: blue;
}
.center {
position: absolute;
left:300px;
right:300px;
background-color: black;
height: 100px;
}
</style>
</head>
<body>
<div class="father">
<div class="left">1</div>
<div class="center">2</div>
<div class="right">3</div>
</div>
</body>
</html>CSS優(yōu)化
(1)壓縮 (2)屬性連寫(xiě): font :font-style font-weight font-size (3)繼承:font clolr (4) CSS放入Head中,減少reflow repaint
以上是“CSS語(yǔ)法的常用技巧有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
分享名稱(chēng):CSS語(yǔ)法的常用技巧有哪些
文章來(lái)源:http://chinadenli.net/article34/ggjepe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、定制網(wǎng)站、網(wǎng)站內(nèi)鏈、網(wǎng)站維護(hù)、移動(dòng)網(wǎng)站建設(shè)、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)