CSS技術在網頁設計中的運用執行個體解析

來源:互聯網
上載者:User
css|設計|網頁|網頁設計   多層模式表單(Cascading Style Sheet, CSS)是一種為超文本置標語言(HyperText Markup anguage, HTML)提供增強補充服務的技術,可對每一個HTML的置標(tag)做精雕細刻的修飾。只用HTML製作的網頁,對頁面內各部分的修飾能力有限且語句煩鎖,CSS正是彌補這一缺陷的有力技術,它語句、文法簡單,只要在源碼中插入STYLE語句就可輕易實現頁面內任意文本顏色、背景、邊框、行距、字距的添刪和修飾等功能,使網頁更加生動活潑,從而獲得滿意的效果。

  CSS在HTML中以STYLE標識出現,其格式為:一對代表CSS技術的STYLE置標,內放被修飾的HTML置標,置標的CSS屬性放於緊隨其後的一對大括弧內,每個屬性賦值用":",多個屬性之間用";"隔開,例:

lt; style > a{text-decoration:none;color:yellow} a:hover{text-decoration:underline; color:purple} {font-size:20; background:red;color:blue} lt; /style >

  將如上代碼插入任一HTML文檔後,重新整理顯示,則所有錨點變為普通字型,顏色為黃,但當滑鼠移至其上時,則錨點的提示字元變為帶底線的紫色字型;整個文檔中被置標P包圍的文字將以紅底藍字、字型大小為20個象素的形式出現。如果其中某段文字需另加修飾,可以單獨的的形式出現,例如:

lt;p style="font-size:30;font-weight :bolder; background:white;color:blue" > ................ lt; /p >

  則此段文字白底藍字,30個象素大小,且字型加粗。隨後是一個帶有CSS技術的HTML文檔的完整例子:

lt; html > lt; head > lt; title >如何使用CSS < /title > lt; /head > lt; body > lt; style > a{text-decoration:none; background:red; color:yellow} a:hover{text-decoration:line-through;background:lime} h1{text-align:center; font-weight:900; order-style:ridge;border-width:medium;border-color:red} .first{font-size:15; font-face:楷體; color:blue;border-style:dotted; order-width:thin;border-color:blue} .second{font-size:20;word-spacing:10;background:aqua} lt; /style > lt;h1 > 帶連框的題頭1 < /h1 > lt; a href=mailto:wow20000@hotmail.com?subject=CSS >

  滑鼠移至此處, 背景變化

lt; /a > lt;p > 未加CSS修飾的段落 < /p > lt; p class=first > 指定CSS修飾的段落< /p > lt;p class=second > 指定另一種CSS修飾的段落 < /p > lt; /body > lt;/html >

  從上例的顯示可以看出,CSS是HTML的一個補充,幾乎可以對每一個HTML置標進行擴充,使網頁充滿活力,顯示出更加完美的效果。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.