跳到主要內容

善用 DIV 做版面配置

以往 用table 編排網頁的方式, 容易產生複雜的原始碼, 適當的善用div 將會乾淨許多, 也減輕(版面 & 程式) 設計者的負擔, 舉例:

<table>
<tbody><tr>
<td>第一列</td>
</tr>
<tr>
<td>第二列</td>
</tr>
</tbody>
</table>

用div呈現會變成

<div>第一列</div>
<div>第二列</div>

所以在版面配置時, div 是個好幫手, 但在列表式的資料編排, 我還是會採用 Table, 部分設計師想盡辦法不使用 Table, 我並不贊成, 何苦呢 ? 將 Table 用在列表式的資料上, 簡單又方便, 通常只要掌握大方面 Table-less Css Layout , 就是一張漂亮的網頁。

如何用 div 做版面配置? 首先要會用 CSS, 需要學很久嗎? 不用, 請打開Dreamweaver CS4 , "新增空白網頁" 可以選擇各式各樣的版面, 三欄、二欄任你挑, 再依照說明文字的解釋去修改你要的寬度就可以。

在body之前會有一串文字如下方,
<!--[if IE]><br /><style type="text/css"><br />/* 在這個條件註解中,放置所有 IE 版本的 CSS 修正 */<br />............<br /></style><br /><![endif]-->

這是為了網頁在各家瀏覽器上可以呈現相同的結果, 因為標題(<h1>,</h1><h2>,<hn...>
)與<p>的使用各家瀏覽器預設內外距的差異, 造成頁面呈現的不統一, 建議做內外距的歸零動作即可, 如下:
h1, h2, h3, p {padding:0;
margin:0
}

最後提供以下版型配置的網站, 有了這些資源, 相信用 DIV 做版面配置, 已經不是惱人的事。

留言

這個網誌中的熱門文章

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/