




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
WebSitesDesignandProgrammingLecturer:LijieGuoRoom:XNA508Phone:23678517Email:2024/5/261CascadingStyleSheets(CSS)WDP[CN]第六章,148-191WDP[EN]Chapter6,188-238
P3W[CN]第三章,70-962024/5/262OverviewMotivationLevelsofstylesheetsStylespecificationformatsSelectorformsPropertyvalueformsExamplesofproperties–font,list,color,textalignment,backgroundimages2024/5/263MotivationConsiderthemanagementofacorporatewebsiteSiteidentity(look&feel-e.g.corporateimage)mustbemaintainedChangesinsiteidentitymustbeimplementedacrosstheentiresiteAmixtureofcontentandappearanceinadatasetisdifficulttomaintainStylesheetconceptfromDTPXHTMLnecessarilymixesstyleandcontent,butstylesheetshelptheseparation2024/5/264CSSCSSprovidesthemeanstocontrolandchangepresentationofXHTMLdocumentsCSSisnottechnicallyHTML,butcanbeembeddedinHTMLdocumentsStylesheetsallowyoutoimposeastandardstyleonawholedocument,orevenawholecollectionofdocumentsCSS1specificationwasdevelopedin1996CSSlevel2〔1998)revision1(“CSS2.1”)-2004,isaCandidateW3CRecommendationCSS3isunderdevelopment2024/5/265LevelsofStyleSheetsTherearethreelevelsofstylesheetsInline-specifiedforaspecificoccurrenceofatagandapplyonlytothattagThisisfine-grainstyle,whichdefeatsthepurposeofstylesheets-uniformstyleDocument-levelstylesheets-applytothewholedocumentinwhichtheyappearExternalstylesheets-canbeappliedtoanynumberofdocumentsWhenmorethanonestylesheetappliestoaspecifictaginadocument,thelowestlevelstylesheethasprecedenceInasense,thebrowsersearchesforastylepropertyspec,startingwithinline,untilitfindsone(orthereisn’tone)2024/5/266LevelsofStyleSheetsInlinestylesheetsappearinthetagitselfDocument-levelstylesheetsappearintheheadofthedocumentExternalstylesheetsareinseparatefiles,potentiallyonanyserverontheInternetWrittenastextfileswiththeMIMEtypetext/cssA<link>tagisusedtospecifythatthebrowseristofetchanduseanexternalstylesheetfile<linkrel="stylesheet"type="text/css"href="://"></link>Externalstylesheetscanbevalidatedvalidator-upload.html2024/5/267InlineStyleSpecificationStylesheetappearsasthevalueofthestyleattributeGeneralform:
style="property_1:value_1;property_2:value_2;…property_n:value_n;"2024/5/268DocumentStyleSpecificationStylesheetappearsasalistofrulesthatarethecontentofa<style>tagThe<style>tagmustincludethetypeattribute,setto"text/css"<styletype="text/css">rulelist</style>Formoftherules:selector
{property_1:value_1;property_2:value_2;…;property_n:value_n;}ThelistofrulesmustbeplacedinanHTMLcomment,becauseitisnotHTMLCommentsintherulelistmusthaveadifferentform-useCcomments(/*…*/)2024/5/269ExternalStyleSheetSpecificationFormisalistofstylerulesLikethecontentofa<style>tagfordocument-levelstylesheets2024/5/2610SimpleSelectorTheselectorisatagnameoralistoftagnames,separatedbycommasExamples:h1{font_size:24pt;}h2,h3{font_size:20pt;}ContextualselectorsApplystyleonlytoelementsinspecifiedpositioninbodyofdocumentListelementhierarchybodypb{font_size:30pt}
2024/5/2611ClassSelectorUsedtoallowdifferentoccurrencesofthesametagtohavedifferentstylespecificationsAstyleclasshasaname,whichisattachedtoatagnamep.narrow{property/valuelist}p.wide{property/valuelist}Theclassyouwantonaparticularoccurrenceofatagisspecifiedwiththeclassattributeofthetag<pclass="narrow">...</p>...<pclass="wide">...</p>2024/5/2612GenericSelectorsAgenericclasscanbedefinedifyouwantastyletoapplytomorethanonekindoftagAgenericclassmustbenamed,andthenamemustbeginwithaperiod.really-big{…}Useinbodyofdoclikenormalstyleclass
<h1class="really-big">…</h1>...<pclass="really-big">…</p>2024/5/2613idSelectorsAnidselectorallowtheapplicationofastyletoonespecificelementGeneralform:
#specific-id{property-valuelist}e.g.#section3{font-size:20}InXHMTLdoc:
<h2id=“section3”>
3.Propertiesforsale
</h2>2024/5/2614PseudoClassesPseudoclassesarestylesthatapplywhensomethinghappens,ratherthanbecausethetargetelementsimplyexistsNamesbeginwithcolonshoverclassapplieswhenthemousecursorisovertheelementfocusclassapplieswhenanelementhasfocusE.G.WDP-4/pseudo.html2024/5/2615reviewCSSSyntax2024/5/2616reviewNote:OnlyoneclassattributecanbespecifiedperXHTMLelement!DoNOTstartaclassnamewithanumber!ItwillnotworkinMozilla/Firefox.2024/5/2617reviewDoNOTstartaclassnamewithanumber!ItwillnotworkinMozilla/Firefox.<html><head><styletype="text/css">h3{text-align:left;color:black}.right{text-align:right;color:blue}#first{text-align:center;color:red}</style></head><body>
<h3class="right"id="first">Howtodisplay</h3></body></html>Howtodisplay?E.G.WDP-4/first.html2024/5/2618SelectorPRIidSelector>classSelector>Simple(tag)Selector2024/5/2619PropertiesThereare60differentpropertiesin7categories:FontsListsAlignmentoftextMarginsColorsBackgroundsBorders2024/5/2620PropertyValueFormsKeywords-left,small,…Length-numbers,maybewithdecimalpointsUnits:px–pixelsin–inchescm–centimetersmm–millimeterspt–pointspc-picas(12points)em-heightoftheletter‘m’ex-height-heightoftheletter‘x’Nospaceisallowedbetweenthenumberandtheunitspecification,e.g.1.5inisillegal!2024/5/2621PropertyValueFormsPercentage-justanumberfollowedimmediatelybyapercentsignURLvaluesurl(protocol://server/pathname)ColorsColorname,e.g.whiteHexform:#XXXXXX,e.g.#FFFFFFrgb(n1,n2,n3),e.g.rgb(255,255,255)Numberscanbedecimal(0-255)orpercentagesPropertyvaluesareinheritedbyallnestedtags,unlessoverridden2024/5/2622FontPropertiesfont-familyValueisalistoffontnames-browserusesthefirstinthelistithasfont-sizePossiblevalues:alengthnumberoraname,suchassmaller,xx-large,etc.font-styleitalic,oblique(useless),normalfont-weight-degreesofboldnessbolder,lighter,bold,normalfont
-forspecifyingalistoffontpropertiesfont:bolder14ptArialHelveticaOrdermustbe:style,weight,size,fontname(s)E.G.WDP-4/fonts.htm
、fonts2.htm2024/5/2623ListPropertieslist-style-typeOnunorderedlistslist-style-type
canbeusedtospecifytheshapeofthebullets
disc(default),square,orcircleSetitoneitherthe<ul>or<li>tag
<h3>Fruit</h3><ul><listyle="list-style-type:disc">Apple</li><listyle="list-style-type:square">Orange</li><listyle="list-style-type:circle">Pear</li></ul>CoulduseanimageforthebulletsinanunorderedlistExample:<listyle="list-style-image:url(bird.jpg)">2024/5/2624ListPropertieslist-style-typeOnorderedlistslist-style-typecanbeusedtochangethesequencevalues
PropertyvalueSequencetypeFirstfour
decimal
Arabicnumerals
1,2,3,4
upper-alpha
UclettersA,B,C,D
lower-alpha
Lclettersa,b,c,d
upper-roman
UcRomanI,II,III,IV
lower-roman
LcRomani,ii,iii,ivE.G.WDP-4/sequence_types.htm2024/5/2625ColorThecolorpropertyspecifiestheforegroundcolourofelements<styletype=“text/css”>th.red{color:red}th.orange{color:orange}</style>Thebackground-colorpropertyspecifiesthebackgroundcolourofelementsE.G.WDP-4/back_color.htm2024/5/2626AlignmentofTextThetext-indentpropertyallowsindentationTakeseitheralengthora%valueThetext-alignpropertyhasthepossiblevalues,left(thedefault),center,right,orjustifySometimeswewanttexttoflowaroundanotherelement-thefloatpropertyvaluesofleft,right,andnone
(thedefault)E.G.WDP-4/float.htm2024/5/2627BoxModel2024/5/2628BoxModel2024/5/2629BoxModel-BordersBorders–everyelementhasaborder-stylepropertyControlswhethertheelementhasaborderandifso,thestyleoftheborderborder-stylevalues:none,dotted,dashed,anddoubleborder-width–thin,medium(default),thick,oralengthvalueinpixelsBorderwidthcanbespecifiedforanyofthefourborders(e.g.,border-top-width)border-color–anycolorBordercolorcanbespecifiedforanyofthefourborders(e.g.,border-top-color)2024/5/2630BoxModel-Margin
Margin–
thespacebetweentheborderofanelementanditsneighborelementThemarginsaroundanelementcanbesetwithmargin-left,etc.-justassignthemalengthvalue<imgsrc="c210.jpg"style="float:right;margin-left:0.35in;margin-bottom:0.35in"/>2024/5/2631BoxModel-Padding
Padding–thedistancebetweenthecontentofanelementanditsborderControlledbypadding,padding-left,etc.E.G.WDP-4/borders.htmlE.G.WDP-4/marpads.html2024/5/2632BackgroundImagesThebackground-image
property
E.G.WDP-4/back_image.htm
background-repeat
propertyPossiblevalues:repeat(default),no-repeat,repeat-x,orrepeat-ybackground-positionpropertyPossiblevalues:top,center,bottom,left,orright2024/5/2633The<span>and<div>tagsOneproblemwiththefontpropertiesisthattheyapplytowholeelements,whichareoftentoolargeSolution:anewtagtodefineanelementinthecontentofalargerelement-<span>Thedefaultmeaningof<span>istoleavethecontentasitis<styletype="text/css">
.bigred{font-size:24pt;font-family:Ariel;color:red}</style
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 中級(jí)經(jīng)濟(jì)師考試的團(tuán)隊(duì)學(xué)習(xí)與試題及答案
- 市政行業(yè)升級(jí)應(yīng)對(duì)試題及答案
- 李清照的評(píng)價(jià)
- 中級(jí)經(jīng)濟(jì)師政策分析技巧試題及答案
- 2025年監(jiān)理工程師概論法規(guī)考點(diǎn)重點(diǎn)知識(shí)總結(jié)筆記含答案
- 深入研究的項(xiàng)目管理試題及答案
- 2025-2030年集成建筑產(chǎn)業(yè)行業(yè)市場現(xiàn)狀供需分析及投資評(píng)估規(guī)劃分析研究報(bào)告
- 2025-2030年阻隔材料行業(yè)發(fā)展分析及競爭格局與投資戰(zhàn)略研究咨詢報(bào)告
- 2025年經(jīng)濟(jì)法專業(yè)材料試題及答案
- 2025-2030年鎂粉產(chǎn)業(yè)政府戰(zhàn)略管理與區(qū)域發(fā)展戰(zhàn)略研究咨詢報(bào)告
- 6.1 根結(jié)、標(biāo)本的上下關(guān)系
- GB/T 3301-1999日用陶瓷的容積、口徑誤差、高度誤差、重量誤差、缺陷尺寸的測定方法
- GB/T 13928-2002微型往復(fù)活塞空氣壓縮機(jī)
- GB/T 12224-2005鋼制閥門一般要求
- 偷影子的人-大學(xué)語文PPT
- GB/T 11022-2020高壓交流開關(guān)設(shè)備和控制設(shè)備標(biāo)準(zhǔn)的共用技術(shù)要求
- GB 4789.3-2016食品安全國家標(biāo)準(zhǔn)食品微生物學(xué)檢驗(yàn)大腸菌群計(jì)數(shù)
- 裝飾窗簾安裝內(nèi)部驗(yàn)收單
- 同等學(xué)力哲學(xué)學(xué)科綜合考試大綱思考題匯總
- 象鼻嶺無蓋重固結(jié)灌漿試驗(yàn)大綱修定稿
- 2023年中醫(yī)兒科學(xué)考試題庫及答案(通用版)
評(píng)論
0/150
提交評(píng)論