goTOP
May 24, 2015

Table中 col 應用

| |
網頁語言 » CSS | 閱覽(2827) | Posted by apao at 10:33
有時候因為程式 id 呼叫的關係,必須讓 table 的 tags 上不要出現 id 的css 指定,可以利用 col 指定 table內容。

點擊在新視窗中瀏覽此圖片
▲設定前

點擊在新視窗中瀏覽此圖片
▲設定後

head中(/**/ CSS中為註解符號)
<style>
table, th, td {
    border: 1px solid black;
/* width:500px; 寬度也可以加在這裡*/
}
</style>


body中
<div>
<table>
  <colgroup>
    <col span="1" style="background-color:red">
    <col style="background-color:yellow; /*去除註解符號就可以加上寬度 width:500px;*/">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
  <tr>
    <td>5869207</td>
    <td>My first CSS</td>
    <td>$49</td>
  </tr>
</table>
</div>


參考:
http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_col_test




使用 div.class名稱 table{}的方式指定也可以達到不在table上設定id名稱的方式

參考網頁:
http://blog.apao.idv.tw/html5/table/colgroup/
Facebook twitter LINEk
文章来自: 本站原創
Tags: , ,
0 Comment(s)
我要發表評論
暱稱
密碼 [ 訪客無需密碼 ]
電郵
網址
開啟HTML 開啟UBB 開啟表情 隱藏 記住我