2011年3月9日 星期三

CSS - 自訂 物件

自訂 選擇器[1][2]


Number of elements


種類一:CLASS="名稱"



<style type="text/css">

<!--

.one{

color : #cc6699 ; /*文字色彩*/

font-size : 9pt; /*文字大小*/

}


.two{

color : #336699 ; /*文字色彩*/

letter-spacing : 3pt;/*字距*/

font-size : 9pt; /*文字大小*/

}


-->

</style>



<p class="one">這裡的文字是粉色9pt的大 小</p>

<p class="two">這裡的文字是藍色9pt字的距離4pt的大 小</p>

<input class="one" type="text" name="T1" size="20" value="這裡是表單">

<table class="two" width="182"> <tr> <td> 這裡是表格 </td> </tr></table>





種類一:CLASS="名稱"


這裡的文字是粉色9pt的大小


這裡的文字是藍色9pt字的距離4pt的大小



這裡是表格




種類二:ID="名稱"

還有一種方式就是使用 ID,其實這跟上方的意思是相同的,CLASS 選擇器是在前方加上小數點,不同的是ID是在前方加上#,來看下面的範例:可以試試看是不是跟class選擇器範例結果是一樣的


#one{

color : #cc6699 ; /*文字色彩*/

font-size : 9pt; /*文字大小*/

}


#two{

color : #336699 ; /*文字色彩*/

letter-spacing : 3pt;/*字距*/

font-size : 9pt; /*文字大小*/

}




<input id="one" type="text" name="T1" size="20" value="這裡是表單">

<table id="two" width="182"> <tr> <td> 這裡是表格 </td> </tr></table>






這裡是表格


注意 : class 選擇器可以在同一個網頁重複運用, id 選擇器是不可重複使用的



Related Posts:

  • CSS - calendar/* .calendar {}/* 行事曆 */*div.calendar {color:#8A2BE2;background:url(http://l.yimg.com/e/style/14/1484/calendar.jpg) repeat-x left top;padding:15px 5px… Read More
  • CSS - Text-decoration:nonea {color:#333;text-decoration:none;}a:hover {color:#004393;text-decoration:none;}/*a 所有的連結都不要有底線 (text-decoration:none;)a:hover 當滑鼠移到連結的時候,也不要有底線.適用頁面… Read More
  • CSS - Color ChartThere have many color code at this WEB site.Please reference ithttp://htmlhelp.com/cgi-bin/color.cgi… Read More
  • CSS - banner/* banner and pageheader -----------------------------------------*/ #banner { background-image:url(https://blogger.googleusercontent.com/img/b/R… Read More
  • CSS - banner structure#banner|頂端橫幅 #pageheader|頂端橫幅             h1|網誌名稱、網誌描述、目前動態       … Read More

0 意見:

張貼留言