版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 電池制液工操作管理評優(yōu)考核試卷含答案
- 景泰藍(lán)制作工崗前理論實操考核試卷含答案
- 茶葉精制工安全技能強化考核試卷含答案
- 稀土永磁材料工崗前操作能力考核試卷含答案
- 農(nóng)化技術(shù)員QC管理測試考核試卷含答案
- 酒店消防設(shè)備檢查維護(hù)制度
- 酒店客房鑰匙管理規(guī)范制度
- 超市商品銷售及數(shù)據(jù)分析制度
- 浩澤凈水機培訓(xùn)
- 流程培訓(xùn)教學(xué)
- 2025至2030中國飛機燃料電池行業(yè)項目調(diào)研及市場前景預(yù)測評估報告
- 園林綠化養(yǎng)護(hù)標(biāo)準(zhǔn)與作業(yè)流程說明
- 收購五金輔料店協(xié)議合同
- 噴砂車間管理辦法
- 梨狀肌綜合癥康復(fù)指導(dǎo)講課件
- 【SA8000標(biāo)準(zhǔn)(社會責(zé)任標(biāo)準(zhǔn))對我國勞動密集型產(chǎn)業(yè)的影響及應(yīng)對措施研究12000字(論文)】
- 醫(yī)療行業(yè)知識產(chǎn)權(quán)教育的必要性
- 工程搶險勞務(wù)合同協(xié)議
- 傳染病院感防控課件
- 7下英語單詞表人教版
- 涉密人員保密培訓(xùn)
評論
0/150
提交評論