国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

CSS編寫的網頁打開流暢相關知識與注意點

2024-07-11 08:39:50
字體:
來源:轉載
供稿:網友

我們都熟知JavaScript可能會對Web頁面的加載與顯示產生較大的影響,因此我們常常關注JavaScript是不是會占用客戶端較多的資源,然而大部分都會忽略的一件有趣的事情,CSS也會對Web頁面載入的效率產生影響。
  我們羅列了十幾條相關的知識與注意點,大家可以系統的探討一下,讓我們編寫的Web頁面打開更加流暢。
  請不要告訴我,你看不懂E文,只是你不愿意看!!!
  1、Howthestylesystembreaksuprules
  Thestylesystembreaksrulesupintofourprimarycategories.Itiscriticaltounderstandthesecategories,astheyarethefirstlineofdefenseasfarasrulematchingisconcerned.Iusethetermkeyselectorintheparagraphsthatfollow.Thekeyselectorisdefinedtobetherightmostoccurrenceofanidselector,aclassselector,oratagselector.
  1.1、IDRules
  ThefirstcategoryconsistsofthoserulesthathaveanIDselectorastheirkeyselector.

button#backButton{}/*ThisisanID-categorizedrule*/
#urlBar[type="autocomplete"]{}/*ThisisanID-categorizedrule*/
treeitem>treerow>treecell#myCell:active{}/*ThisisanID-categorizedrule*/

  1.2、ClassRules
Ifarulehasaclassspecifiedasitskeyselector,thenitfallsintothiscategory.

button.toolbarButton{}/*Aclass-basedrule*/
.fancyText{}/*Aclass-basedrule*/
menuitem>.menu-left[checked="true"]{}/*Aclass-basedrule*/

  1.3、TagRules
  IfnoclassorIDisspecifiedasthekeyselector,thenthenextpotentialcategoryforaruleisthetagcategory.Ifarulehasatagspecifiedasitskeyselector,thentherulefallsintothiscategory.

td{}/*Atag-basedrule*/
treeitem>treerow{}/*Atag-basedrule*/
input[type="checkbox"]{}/*Atag-basedrule*/

  1.4、UniversalRules
  Allotherrulesfallintothiscategory.

:table{}/*Auniversalrule*/
[hidden="true"]{}/*Auniversalrule*/
*{}/*Auniversalrule*/
tree>[collapsed="true"]{}/*Auniversalrule*/

  2、HowtheStyleSystemMatchesRules
  Thestylesystemmatchesarulebystartingwiththerightmostselectorandmovingtotheleftthroughtherule’sselectors.Aslongasyourlittlesubtreecontinuestocheckout,thestylesystemwillcontinuemovingtotheleftuntiliteithermatchestheruleorbailsoutbecauseofamismatch.
  Yourfirstlineofdefenseistherulefilteringthatoccursbasedonthetypeofthekeyselector.Thepurposeofthiscategorizationistofilteroutrulessothatyoudon’tevenhavetowastetimetryingtomatchthem.Thisisthekeytodramaticallyincreasingperformance.Thefewerrulesthatyouevenhavetocheckforagivenelement,thefasterstyleresolutionwillbe.Asanexample,ifyourelementhasanID,thenonlyIDrulesthatmatchyourelement’sIDwillbechecked.Onlyclassrulesforaclassfoundonyourelementwillbechecked.Onlytagrulesthatmatchyourtagwillbechecked.Universalruleswillalwaysbechecked.
  3、GuidelinesforEfficientCSS
  

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 林甸县| 阿拉善盟| 曲松县| 沧州市| 工布江达县| 兴义市| 原平市| 延吉市| 日喀则市| 新昌县| 会泽县| 富源县| 治县。| 资溪县| 瑞金市| 菏泽市| 金寨县| 通化县| 留坝县| 通许县| 平昌县| 张家港市| 阿合奇县| 通江县| 呈贡县| 紫云| 东海县| 双桥区| 望城县| 贵港市| 图木舒克市| 紫阳县| 兴业县| 栾川县| 禹州市| 浮梁县| 托克托县| 边坝县| 历史| 乐清市| 沅陵县|