日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > CSS >内容正文

CSS

【总有一些东西要弄清】——说说面试时一系列的CSS问题

發(fā)布時間:2023/12/13 CSS 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【总有一些东西要弄清】——说说面试时一系列的CSS问题 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

僅以此篇緬懷那些筆試100次,問100次的CSS問題。

問:

  CSS選擇符有哪些?哪些屬性可以繼承?優(yōu)先級?內(nèi)聯(lián)和important哪個優(yōu)先級高?

選擇符

1通配選擇符(*)表示頁面內(nèi)所有元素的樣式*{font-size:12px;margin:0;padding:0;}
2類型選擇符(body、div、p、span等)網(wǎng)頁中已有的標(biāo)簽類型作為名稱的選擇符div{width:10px;height:10px;}
3群組選擇符(,)對一組對象同時進(jìn)行相同的樣式指派a:link,a:visited{color:#fff;}
4層次選擇符(空格)包含選擇符對某對象中的子對象進(jìn)行樣式指派#header top{width:100px;}
5id選擇符(#)id選擇符具有唯一性,在頁面中不能重復(fù)使用#header{width:300px;}
6class選擇符(.)可以在頁面中重復(fù)使用.title{width:300px;}
7IEhack選擇符(_、*、\0、\9\0;)兼容不同的瀏覽器.title{_width:50px;*height:30px;}

?

可繼承的屬性

azimuth, border-collapse, border-spacing,          //紅色為常用的 caption-side, color, cursor, direction, elevation, empty-cells, font-family, font-size, font-style, font-variant, font-weight, font, letter-spacing, line-height, list-style-image, list-style-position, list-style-type, list-style, orphans, pitch-range, pitch, quotes, richness, speak-header, speaknumeral, speak-punctuation, speak, speechrate, stress, text-align, text-indent, texttransform, visibility, voice-family, volume, whitespace, widows, word-spacing

優(yōu)先級的四大原則

原則1:繼承沒指定的牛B

demo1:

<style type="text/css"> *{font-size:20px} .class3{ font-size: 12px; } </style>
<span class="class3">我是多大字號?</span> <!-- 運(yùn)行結(jié)果:.class3{ font-size: 12px; }-->

demo2:

<style type="text/css"> #id1 #id2{font-size:20px} .class3{font-size:12px} </style> <div id="id1" class="class1"> <p id="id2" class="class2"> <span id="id3" class="class3">我是多大字號?</span> </p> </div> <!--運(yùn)行結(jié)果:.class3{ font-size: 12px; }-->

原則2:#ID > .class > 標(biāo)簽

demo1:

<style type="text/css"> #id3 { font-size: 25px; } .class3{ font-size: 18px; } span{font-size:12px} </style> <span id="id3" class="class3">我是多大字號?</span> <!--運(yùn)行結(jié)果:#id3 { font-size: 25px; }-->

原則3:越具體越牛B

demo1:

<style type="text/css"> .class1 .class2 .class3{font-size: 25px;} .class2 .class3{font-size:18px} .class3 { font-size: 12px; } </style> <div class="class1"> <p class="class2"> <span class="class3">我是多大字號?</span> </p> </div> <!--運(yùn)行結(jié)果:.class1 .class2 .class3{font-size: 25px;}-->

原則4:標(biāo)簽#ID > 標(biāo)簽.class

demo1:

<style type="text/css"> span#id3{font-size:18px} #id3{font-size:12px} span.class3{font-size:18px} .class3{font-size:12px} </style><span id="id3">我是多大字號?</span> <span class="class3">我是多大字號?</span> <!--運(yùn)行結(jié)果:span#id3{font-size:18px} | span.class3{font-size:18px}-->

最后:當(dāng)原則之前沖突的時候,原則1 >?原則2?>?原則3?>?原則4

?

!important

IE6到底認(rèn)不認(rèn)識!important???

  答:認(rèn)識,但是有一個小bug。

例如:

<style> #ida {size:18px} .classb { font-size: 12px; } </style><div id=“ida” class=“classb”>!important測試:18px</div>

加入!important

<style> #ida{font-size:18px} .classb{ font-size: 12px !important; } </style><div id=“ida” class=“classb”>!important測試:12px</div>

IE6 BUG:

<style> .classb{ font-size: 18px !important; font-size: 12px } </style><div class=“classA”>!important測試:12px</div>

原因和辦法:

  這里在ie6下是12像素的字,而其他瀏覽器下是18px的字。

  但是當(dāng)我們把樣式改一下,!important放在后面,即.classb{ font-size: 12px;font-size: 18px !important; },那么ie6下和其他瀏覽器一樣也是18px的字。

  

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/ccto/archive/2013/03/19/2970309.html

總結(jié)

以上是生活随笔為你收集整理的【总有一些东西要弄清】——说说面试时一系列的CSS问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。