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

云俄罗斯VPSJusthost俄罗斯VPS云服务器justg:JustHost、RuVDS、JustG等俄罗斯vps主机

俄罗斯vps云服务器商家推荐!俄罗斯VPS,也叫毛子主机(毛子vps),因为俄罗斯离中国大陆比较近,所以俄罗斯VPS的延迟会比较低,国内用户也不少,例如新西伯利亚机房和莫斯科机房都是比较热门的俄罗斯机房。这里为大家整理推荐一些好用的俄罗斯VPS云服务器,这里主要推荐这三家:justhost、ruvds、justg等俄罗斯vps主机,方便大家对比购买适合自己的俄罗斯VPS。一、俄罗斯VPS介绍俄罗斯...

LOCVPS新上日本软银线路VPS,原生IP,8折优惠促销

LOCVPS在农历新年之后新上架了日本大阪机房软银线路VPS主机,基于KVM架构,配备原生IP,适用全场8折优惠码,最低2GB内存套餐优惠后每月仅76元起。LOCVPS是一家成立于2012年的国人VPS服务商,提供中国香港、韩国、美国、日本、新加坡、德国、荷兰、俄罗斯等地区VPS服务器,基于KVM或XEN架构(推荐选择KVM),线路方面均选择国内直连或优化方案,访问延迟低,适合建站或远程办公使用。...

AlphaVPS(€3.99/月)VPS年付15欧,AMD EYPC+NVMe系列起

AlphaVPS是一家保加利亚本土主机商(DA International Group Ltd),提供VPS主机及独立服务器租用等,数据中心包括美国(洛杉矶/纽约)、德国、英国和保加利亚等,公司办公地点跟他们提供的保加利亚数据中心在一栋楼内,自有硬件,提供IPv4+IPv6,支持PayPal或者信用卡等方式付款。商家提供的大硬盘VPS主机,提供128GB-2TB磁盘,最低年付15欧元起,也可以选择...

csshack为你推荐
支持ipad支持ipadwin7关闭445端口如何快速关闭445端口win10445端口win7系统不能被telnet端口号,端口、服务什么全都开了127.0.0.1127.0.0.1打不开迅雷快鸟迅雷快鸟支持移动宽带提速吗kb4012598win7怎么查看电脑是否安装了 ms17 010google统计google分析里的数据包括搜索引擎爬虫的数据吗?Google中文专题交流杀毒软件免费下载2013排行榜哪里有免费好用的杀毒软件ios10.0.3苹果10.03系统怎么样
php空间租用 动态域名解析软件 主机屋 winhost 免费ftp空间 lighttpd 一点优惠网 本网站在美国维护 已备案删除域名 卡巴斯基破解版 腾讯总部在哪 网站加速软件 游戏服务器出租 php服务器 1美元 ssl加速 网络速度 phpinfo winserver2008r2 hosting 更多