跳到主要內容

運用CSS設計表格

為了搭配網站風格與版面配置, 枯燥的表格也需要多樣化, 只要將htm語法做結構化的設計, 加上CSS, 就可重複運用表格樣式, 簡單又快速。
  • 設計表格時, 我喜歡這樣做

    • <table id="Nclass" summary="簡要說明">
      <thead>
      <tr>
      <th scope="col">欄1</th>
      <th scope="col">欄2</th>
      <th scope="col">欄3</th>
      <th scope="col">欄4</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>A1</td>
      <td>A2</td>
      <td>A3</td>
      <td>A4</td>
      </tr>
      <tr>
      <td>B1</td>
      <td>B2</td>
      <td>B3</td>
      <td>B4</td>
      </tr>
      <tr>
      <td>C1</td>
      <td>C2</td>
      <td>C3</td>
      <td>C4</td>
      </tr>
      <tr>
      <td>D1</td>
      <td>D2</td>
      <td>D3</td>
      <td>D4</td>
      </tr>
      </tbody>
      </table>


  • CSS可以這樣設計



    • #Nclass thead
      {....}

      #Nclass tbody
      {....}

      #Nclass tfoot
      {....}

      也可針對td
      #Nclass tbody td
      {....}



  • 如果看不懂, 請參考此處下載檔案 http://www.smashingmagazine.com/2008/08/13/top-10-css-table-designs/
  • 上方檔案使用時請注意 border-collapse: collapse 於Firefox2 使用上會有錯誤,兩個方法解決

    • 左右不設邊界
    • 將table的cellpadding設定為"0", 如下:

      <table cellpadding="0" .....


      想要知道原因,請參考此處
    • http://stackoverflow.com/questions/1035706/firefox-1-pixel-bug-with-border-collapse-workaround


  • 以上只是個人習慣, 若想更深入運用table, 請參考此處
    http://www.w3.org/TR/CSS21/tables.html

留言

這個網誌中的熱門文章

Indexed Database API - Initail

As a front web developer, I could create UI faster or Optimize file to load page faster. But it hard to faster response time form server however 80-90% of the end-user response time is spent on the frontend. Nowadays we could use the Indexed Database API, or IndexedDB to reduce the request times. Less request times, less response time. What is IndexedDB ? IndexedDB is web browser standard interface for a local database of records holding simple values and hierarchical objects. IndexedDB was initially proposed by Oracle in 2009./* wiki */ What browsers would support IndexedDB ? Most browsers of hybrid devices support it exclude IE9-, Safari 7-,iOS Safari 7.1-, Opera Mini, Android Browser 4.3-./* caniuse.com */ When shall we use IndexedDB ? Save Money on web hosting Data index sort Data keyword search Keep data for period of time How to start it? //*************************************************************** //initDB //{Object}, {data: dbName, objectStore: storeName, ...

最近設計的一組icon..太有APPLE風格被打槍了

jQuery 的slideToggle太好用了

$ ( ".collapse" ) .each ( function ( index, value ) { $ ( this ) . click ( function ( evt ) { evt.preventDefault ( ) ; //prevent the default click event of the anchor tag. var target = $ ( this ) .attr ( "data-toggle" ) ; $ ( "." + target ) .slideToggle ( ) ; } ) ; } ) ; http://code-tricks.com/create-a-common-toggler-for-div-using-jquery/