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;}!
!
!
!
!
!

美国Cera 2核4G 20元/45天 香港CN2 E5 20M物理机服务器 150元 日本CN2 E5 20M物理机服务器 150元 提速啦

提速啦 成立于2012年,作为互联网老兵我们一直为用户提供 稳定 高速 高质量的产品。成立至今一直深受用户的喜爱 荣获 “2021年赣州安全大赛第三名” “2020创新企业入围奖” 等殊荣。目前我司在美国拥有4.6万G总内存云服务器资源,香港拥有2.2万G总内存云服务器资源,阿里云香港机房拥有8000G总内存云服务器资源,国内多地区拥有1.6万G总内存云服务器资源,绝非1 2台宿主机的小商家可比。...

bgpto:BGP促销,日本日本服务器6.5折$93/月低至6.5折、$93/月

bgpto怎么样?bgp.to日本机房、新加坡机房的独立服务器在搞特价促销,日本独立服务器低至6.5折优惠,新加坡独立服务器低至7.5折优惠,所有优惠都是循环的,终身不涨价。服务器不限制流量,支持升级带宽,免费支持Linux和Windows server中文版(还包括Windows 10). 特色:自动部署,无需人工干预,用户可以在后台自己重装系统、重启、关机等操作!bgpto主打日本(东京、大阪...

Atcloud:全场8折优惠,美国/加拿大/英国/法国/德国/新加坡vps,500g大硬盘/2T流量/480G高防vps,$4/月

atcloud怎么样?atcloud刚刚发布了最新的8折优惠码,该商家主要提供常规cloud(VPS)和storage(大硬盘存储)系列VPS,其数据中心分布在美国(俄勒冈、弗吉尼亚)、加拿大、英国、法国、德国、新加坡,所有VPS默认提供480Gbps的超高DDoS防御。Atcloud高防VPS。atcloud.net,2020年成立,主要提供基于KVM虚拟架构的VPS、只能DNS解析、域名、SS...

csshack为你推荐
人文社科winrar投标人chrome支持ipad支持ipad责任编辑:纪春Deviceios5css3圆角用CSS3怎么实现圆角边框?勒索病毒win7补丁怎么删除 防勒索病毒 打的补丁勒索病毒win7补丁win7有针对勒索病毒的补丁吗ipadwifiipad wifi信号差怎么办
备案域名 花生壳动态域名 ip查域名 中文国际域名 国内vps 播放vps上的视频 域名服务器的作用 国外永久服务器 liquidweb 便宜域名 winhost 台湾服务器 云图标 国内加速器 丹弗 双拼域名 网站cdn加速 最好的免费空间 徐正曦 免费phpmysql空间 更多