css題

一.CSS 選擇符有哪些?哪些屬性能夠繼承?優先級算法如何計算?
1.id選擇器( # myid) 2.類選擇器(.myclassname)3.標籤選擇器(div, h1, p)  4.相鄰選擇器(h1 + p)
5.子選擇器(ul < li)    6.後代選擇器(li a)
7.通配符選擇器( * ) 9.僞類選擇器(a: hover, li: nth - child)
可繼承的樣式: font-size font-family color, ul li dl dd dt;
不可繼承的樣式:border padding margin width height ;
 優先級就近原則,同權重狀況下樣式定義最近者爲準;
 載入樣式以最後載入的定位爲準;
 優先級爲:
  !important > id > class > tag important 比 內聯優先級高
CSS3新增僞類有那些?
p:last-of-type 選擇其父元素的最後的一個P元素
p:first-of-type 選擇其父元素的首個P元素
p:nth-child(n)   選擇其父元素的第N個 恰好是p的元素
p:nth-last-child(n) ..............................................從最後一個子元素開始計數
p:nth-of-type(n)  選擇其父元素的n個元素
p:nth-last-of-type(n) ........................從最後一個子元素開始計數
二.css水平、垂直居中的寫法,請至少寫出4種?
水平居中
行內元素: text-align: center
塊級元素: margin: 0 auto
position:absolute +left:50%+ transform:translateX(-50%)
display:flex + justify-content: center
垂直居中
設置line-height 等於height
position:absolute +top:50%+ transform:translateY(-50%)
display:flex + align-items: center
display:table+display:table-cell + vertical-align: middle;
三.畫一條0.5px的直線?
考查的是css3的transform
height: 1px;
transform: scale(0.5);縮放
四.s說一下盒模型?
盒模型是css中重要的基礎知識,也是必考的基礎知識
盒模型的組成,由裏向外content,padding,border,margin.
在IE盒子模型中,width表示content+padding+border這三個部分的寬度
在標準(w3c)的盒子模型中,width指content部分的寬度
box-sizing的使用
box-sizing: content-box 是W3C盒子模型
box-sizing: border-box 是IE盒子模型
box-sizing的默認屬性是content-box
五.清除浮動的最經常使用的四種方法,以及優缺點
1.額外標籤法(在最後一個浮動標籤後,新加一個標籤,給其設置clear:both;)(不推薦)
2.父級添加overflow屬性(父元素添加overflow:hidden)(不推薦)
3.使用after僞元素清除浮動(推薦使用)
.clearfix:after{/*僞元素是行內元素 正常瀏覽器清除浮動方法*/
content: "";
display: block;
height: 0;
clear:both;
visibility: hidden;
}
.clearfix{
*zoom: 1;/*ie6清除浮動的方式 *號只有IE6-IE7執行,其餘瀏覽器不執行*/
}
4.使用before和after雙僞元素清除浮動
.clearfix:after,.clearfix:before{
content: "";
display: table;
}
.clearfix:after{
clear: both;
}
.clearfix{
*zoom: 1;
}
六。說一下<label>標籤的用法
label標籤主要是方便鼠標點擊使用,擴大可點擊的範圍,加強用戶操做體驗
css3實現一個三角形 等腰
<div class="kailong"></div>css

.kailong{
width:0;
height:0;
border-right:50px solid transparent;
border-left:50px solid transparent;
border-bottom:50px solid red;
}
css3新特性
1.實現圓角 boder-radius
2.對文字加特效boder-shadow(陰影) rgba(透明度)
3.旋轉,縮放,定位,傾斜 :transform:適用於2D或3D轉換的元素 scale
.過渡transition: CSS屬性,花費時間,效果曲線(默認ease),延遲時間(默認0)
/*寬度從原始值到制定值的一個過渡,運動曲線ease,運動時間0.5秒,0.2秒後執行過渡*/
transition:width,.5s,ease,.2s
4.動畫 /*執行一次logo2-line動畫,運動時間2秒,運動曲線爲 linear*/
animation: logo2-line 2s linear;
5.flex 彈性佈局 box {
display: flex;
justify-content: center;
} 水平居中
.box {
display: flex;
align-items: center;
} 垂直居中css3

相關文章
相關標籤/搜索