documentcss

csshack  时间:2021-02-11  阅读:()
CSSCASCADETypesofstylesheetsHTMLdocumentsmayhavethreetypesofstylesheetsappliedtothem.
Type1:User-agentstylesIfyoulookatawebpageinabrowser,evenawebpagewithoutanyCSSleattached,therearesomestylesalreadyinplace.
Headingsareoftenlargerinsize.
Unvisitedlinksareoftenblue,visitedlinksareoftenpurpleandallgeneralcontentisoftenblack.
ThisisbecauseallbrowsershavetheirownstylesheetthatisusedtodenethedefaultbehaviourofHTMLelements.
Thisstylesheetismoreaccuratelyreferredtoasa"user-agent"stylesheet.
Type2:Userstyles"Users"arethepeoplewhovisitourwebsitesandinteractwithourcontent.
Manybrowsershavesomesortofmechanismthatallowsuserstowritetheirownstylesheetorstylesheets.
Thesestylesheetsarereferredtoas"userstylesheets".
Userstylesheetsallowsuserstooverridestylesheetsforspecicwebsitesorforallwebsitesthattheyvisit.
Anexamplecouldbeauserwithavisionimpairmentwhowritesastylesheetthatturnsalltextwhiteandthepagebackgroundtoblack-tomakecontenteasiertoread.
Type3:AuthorstylesAswebauthors,wecanusethreedierentmethodstoapplyCSSstylestoanyHTMLdocument.
InlinestylesareappliedtoelementsintheHTMLmarkupusingthe"style"attribute.
!
!
!
Contenthere!
HeaderstylesareplacedintheheadofHTMLdocumentsusingtheelement.
!
!
!
!
!
!
Sitename!
!
!
!
!
p{color:green;}!
!
!
!
!
!
Externalstylesheetsareappliedusingelement.
!
!
!
!
!
!
Sitename!
!
!
!
!
!
NormalvsimportantUsersandauthorscandeneanydeclarationas"moreimportant"thanotherdeclarations.
Importantdeclarationsarewrittenwiththe"!
"delimitertokenand"important"keywordfollowingthedeclaration.
/*exampleofimportant*/!
h2{color:red!
important;}Aswewillseesoon,theCSSCascadetreatsimportantdeclarationsdierentlytonormaldeclarations.
UnderstandingConictBrowsers(oruser-agents)havetodealwithCSSrulescomingfromthesethreedierentorigins-user-agent,userandauthor.
BrowsershavetodealwithCSSrulescomingfromdierenttypesofauthorstylesheets-inlinevsheadervsexternal.
Browsersalsohavetodealwithdierenttypesofdeclarations-importantvsnormal.
Atsomepoint,browsershavetodealwithdeclarationsthatconict.
Conictiswheremorethanonedeclarationreferstothesameelementandproperty.
/*conflictingrules*/!
h2{color:blue;}!
h2.
intro{color:green;}!
.
containerh2{color:red;}Whenconictoccurs,browsersneedtodeterminewhichdeclarationswill"win"(beappliedtoanHTMLdocument).
InCSS2.
1,therearefourstepstodeterminewhichdeclarationwill"win".
Step1GatherthedeclarationsBrowsersmustgatherallthedeclarationsthatapplytoanelementandpropertyfromuser-agent,userandauthorstylesheets.
Forexample,browsershavetogatheranydeclarationsthatmatch:element=h2property=color/*user-agentstyles*/!
h2{color:black;}!
!
/*userstyles*/!
h2{color:green;}!
!
/*authorstyles*/!
h2{color:blue;}!
#navh2{color:lime;}!
!
Iftherearedeclarationsfrommorethanoneofthesethreesources,proceedtostep2.
Step2SortbyoriginandimportanceForthissecondstep,thegathereddeclarationsaresortedaccordingtoorigin(user-agent,user,author)andimportance(normalorimportant).
InCSS2.
1,therearevestepstodeterminehowdeclarationsaresorted.
Fromlowesttohighestpriority!
1.
Normaluser-agentdeclarations2.
Normaluserdeclarations3.
Normalauthordeclarations4.
Importantauthordeclarations5.
ImportantuserdeclarationsIfnootherdeclarationsexist,user-agentdeclarationswin.
/*user-agentstyles*/!
h2{color:black;}Normaluserdeclarationsbeatuser-agentdeclarations.
/*user-agentstyles*/!
h2{color:black;}!
!
/*userstyles*/!
h2{color:green;}Normalauthordeclarationsbeatuser-agentdeclarationsandnormaluserdeclarations.
/*user-agentstyles*/!
h2{color:black;}!
!
/*userstyles*/!
h2{color:green;}!
!
/*authorstyles*/!
h2{color:blue;}Importantauthordeclarationsbeatallnormaldeclarations.
/*user-agentstyles*/!
h2{color:black;}!
!
/*userstyles*/!
h2{color:green;}!
!
/*authorstyles*/!
h2{color:blue;}!
h2{color:purple!
important;}Importantuserdeclarationsbeatimportantauthordeclarationsandallnormaldeclarations.
/*user-agentstyles*/!
h2{color:black;}!
!
/*userstyles*/!
h2{color:green;}!
h2{color:red!
important;}!
!
/*authorstyles*/!
h2{color:blue;}!
h2{color:purple!
important;}Butwhatiftwodeclarationshavethesameoriginorimportance/*user-agentstyles*/!
h2{color:black;}!
!
/*userstyles*/!
h2{color:green;}!
h2{color:red;}!
!
/*authorstyles*/!
h2{color:blue;}!
h2{color:lime;}!
!
IfdeclarationshavethesameoriginorimportancethenproceedtoStep3.
Step3DeterminespecicityIfdeclarationshavethesameoriginorimportancethenthedeclaration'sselectorsneedtobescoredtoseewhichdeclarationwill"win".
Fourscoresareconcatenated(linkedtogetherasachain)tocreateanalscore.
Thisscoreisreferredtoasaselector'sspecicity.
!
selectorspecicity=a,b,c,dHowisspecicitycalculatedA.
Isthereaninlinestyle!
!
!
a=1xinlinestyles!
b=0xIDs!
c=0xclasses,pseudo-classes,attributes!
d=0xelements,pseudo-elements!
!
Specificity=1,0,0,0B.
CountthenumberofIDselectorsintheselector.
#nav{}!
!
!
a=0xinlinestyles!
b=1xIDs!
c=0xclasses,pseudo-classes,attributes!
d=0xelements,pseudo-elements!
!
Specificity=0,1,0,0!
C.
Countthenumberofclassselectors,attributeselectorsorpseudo-classselectorsintheselector.
.
intro{}!
!
!
a=0xinlinestyles!
b=0xID!
c=1xclasses,pseudo-classes,attributes!
d=0xelements,pseudo-elements!
!
Specificity=0,0,1,0!
D.
Countthenumberofelementtypeorpseudo-elementselectorsintheselector.
p{}!
!
!
a=0xinlinestyles!
b=0xID!
c=0xclasses,pseudo-classes,attributes!
d=1xelements,pseudo-elements!
!
Specificity=0,0,0,1E.
Ignoretheuniversalselector.
*{}!
!
!
a=0xinlinestyles!
b=0xID!
c=0xclasses!
d=0xelement!
!
Specificity=0,0,0,0Someexamples#navul{}!
!
!
a=0xinlinestyles!
b=1xID(#nav)!
c=0xclasses!
d=1xelement(ul)!
!
Specificity=0,1,0,1blockquote.
special{}!
!
!
a=0xinlinestyles!
b=0xIDs!
c=1xclass(.
special)!
d=1xelement(blockquote)!
!
Specificity=0,0,1,1a:link{}!
!
!
a=0xinlinestyles!
b=0xIDs!
c=1xpseudo-class(:link)!
d=1xelements(a)!
!
Specificity=0,0,1,1input[required]{}!
!
!
a=0xinlinestyles!
b=0xIDs!
c=1xattributeselector([required])!
d=1xelements(input)!
!
Specificity=0,0,1,1p[class="a"]{}!
!
!
a=0xinlinestyles!
b=0xIDs!
c=1xattributeselector([class="a"])!
d=1xelements(p)!
!
Specificity=0,0,1,1div[id="news"]{}!
!
!
a=0xinlinestyles!
b=0xIDs!
c=1xattributeselector([id="news"])!
d=1xelements(div)!
!
Specificity=0,0,1,1::first-line{}!
!
!
a=0xinlinestyles!
b=0xIDs!
c=0xclasses!
d=1xpseudo-element(::first-line)!
!
Specificity=0,0,0,1#navullia:hover{}!
!
!
a=0xinlinestyles!
b=1xID(#nav)!
c=1xpseudo-class(:hover)!
d=3xelements(ul,li,a)!
!
Specificity=0,1,1,3AnoteonconcatenationGenerallyspeaking,"A"willalwaysbeat"B",whichwillalwaysbeat"C",whichwillalwaysbeat"D".
NomatterhowmanyIDsareusedinaselector,aninlinestylewillalwaysbeatanIDselector.
Inthefollowingexample,theinlinestylewinsduetospecicity-1,0,0,0beats0,10,0,0.
/*authorstyles*/!
#one#two#three#four#five#six#seven#eight#nine#ten!
{color:green;}!
!
!
!
Theoretically,nomatterhowmanyclassesareappliedtoaselector,anIDwillalwaysbeatclasses.
!
(Firefoxbrowsersincorrectlyimplementthespecicationsothat256classeswill"beat"anID)Inthefollowingexample,theIDselectorwinsduetospecicity-0,1,0,0beats0,0,10,0.
/*authorstyles*/!
.
one.
two.
three.
four.
five.
six!
.
seven.
eight.
nine.
ten!
{color:green;}#nav{color:lime;}Theoretically,nomatterhowmanyelementtypesareappliedtoaselector,aclasswillalwaysbeatelementtypes.
!
(Firefoxbrowsersincorrectlyimplementthespecicationsothat256elementtypeswill"beat"aclass)Inthefollowingexample,theclassselectorwinsduetospecicity-0,0,1,0beats0,0,0,10.
/*authorstyles*/!
divdivdivdivdivdivdivdivdivdiv{color:green;}.
intro{color:lime;}WhatifthereisstillnoclearwinnerInthefollowingexample,twoauthorstyleshavethesamespecicity.
/*authorstyles*/!
.
introh2{color:blue;}!
h2.
new{color:lime;}!
!
!
!
!
!

俄罗斯vps主机推荐,怎么样俄罗斯vps俄罗斯vps速度怎么样?

俄罗斯vps速度怎么样?俄罗斯vps云主机节点是欧洲十大节点之一,地处俄罗斯首都莫斯科,网络带宽辐射周边欧洲大陆,10G专线连通德国法兰克福、法国巴黎、意大利米兰等,向外连接全球。俄罗斯vps云主机速度快吗、延迟多少?由于俄罗斯数据中心出口带宽充足,俄罗斯vps云主机到全球各地的延迟、速度相对来说都不错。今天,云服务器网(yuntue.com)小编介绍一下俄罗斯vps速度及俄罗斯vps主机推荐!俄...

特网云57元,香港云主机 1核 1G 10M宽带1G(防御)

特网云官網特网云服务器在硬件级别上实现云主机之间的完全隔离;采用高端服务器进行部署,同时采用集中的管理与监控,确保业务稳定可靠,搭建纯SSD架构的高性能企业级云服务器,同时采用Intel Haswell CPU、高频DDR4内存、高速Sas3 SSD闪存作为底层硬件配置,分钟级响应速度,特网云采用自带硬防节点,部分节点享免费20G防御,可实现300G防御峰值,有效防御DDoS、CC等恶意攻击,保障...

零途云月付31.9元起,香港cn2 gia线路

零途云是一家香港公司,主要产品香港cn2 gia线路、美国Cera线路云主机,美国CERA高防服务器,日本CN2直连服务器;同时提供香港多ip站群云服务器。即日起,购买香港/美国/日本云服务器享受9折优惠,新用户有优惠码:LINGTUYUN,使用即可打折。目前,零途云还推出性价比非常高香港多ip站群云服务器,有需要的,可以关注一下。零途云优惠码:优惠码:LINGTUYUN (新用户优惠,享受9折优...

csshack为你推荐
档案管理系统常见问题及解决办法"2018年中文图书第5期新书通报",,,,,参考手册NDXS和ND5XS网络音频播放器中文目录支付apple中平迅雷大学生就业信息获取与信息分析奶粉ios8支持ipaditunes备份itunes 里面的资料如何备份?用itunes备份如何使用itunes完整备份iPhone资料
香港主机租用 什么是域名解析 yardvps linode代购 优key 免费cdn加速 美国php空间 国外网站代理服务器 太原联通测速平台 softbank邮箱 699美元 服务器干什么用的 福建铁通 789 摩尔庄园注册 酸酸乳 1美元 好看的空间 privatetracker cx域名 更多