您好,登錄后才能下訂單哦!
小編給大家分享一下css常用技巧是什么,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
1、三角形列表項(xiàng)目符號(hào)
ul { margin: 0.75em 0; padding: 0 1em; list-style: none;}li:before { content: ""; border-color: transparent #111; border-style: solid; border-width: 0.35em 0 0.35em 0.45em; display: block; height: 0; width: 0; left: -1em; top: 0.9em; position: relative;}
2、外部CSS3 盒陰影
#mydiv { -webkit-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52); -moz-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52); box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);}
3、內(nèi)部CSS3 盒陰影
#mydiv { -moz-box-shadow: inset 2px 0 4px #000; -webkit-box-shadow: inset 2px 0 4px #000; box-shadow: inset 2px 0 4px #000;}
4、CSS3 斑馬線(xiàn)
tbody tr:nth-child(odd) { background-color: #ccc;}
5、強(qiáng)制出現(xiàn)垂直滾動(dòng)條
html { height: 101% }
6、內(nèi)容垂直居中
.container { min-height: 6.5em; display: table-cell; vertical-align: middle;}
7、CSS3:全屏背景
html { background: url('images/bg.jpg') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;}
8、錨鏈接偽類(lèi)
a:link { color: blue; }a:visited { color: purple; }a:hover { color: red; }a:active { color: yellow; }
9、為logo隱藏H1
h2 { text-indent: -9999px; margin: 0 auto; width: 320px; height: 85px; background: transparent url("images/logo.png") no-repeat scroll;}
10、自定義文本選擇
::selection { background: #e2eae2; }::-moz-selection { background: #e2eae2; }::-webkit-selection { background: #e2eae2; }
11、跨瀏覽器的透明
.transparent { filter: alpha(opacity=50); /* internet explorer */ -khtml-opacity: 0.5; /* khtml, old safari */ -moz-opacity: 0.5; /* mozilla, netscape */ opacity: 0.5; /* fx, safari, opera */}
12、新版清除浮動(dòng)(2011)
.clearfix:before, .container:after { content: ""; display: table; }.clearfix:after { clear: both; }/* IE 6/7 */.clearfix { zoom: 1; }
13、典型的CSS清除浮動(dòng)
.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }.clearfix { display: inline-block; }html[xmlns] .clearfix { display: block; }* html .clearfix { height: 1%; }
14、制造模糊文本
想要讓文本模糊?可以使用color透明和text-shadow實(shí)現(xiàn)
.blurry-text { color: transparent; text-shadow: 0 0 5px rgba(0,0,0,0.5);}
15、CSS:表格列寬自適用
對(duì)于表格,當(dāng)談到調(diào)整列寬時(shí),是比較痛苦的。然后,這里有一個(gè)可以使用的技巧:給td元素添加white-space: nowrap;能讓文本正確的換行
td { white-space: nowrap;}
以上是“css常用技巧是什么”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。