[翻譯][HTML]CELLPADDING and CELLSPACING

來源:互聯網
上載者:User

標籤:blog   http   os   io   使用   strong   ar   for   2014   

w3school手冊:http://www.w3schools.com/tags/att_table_cellspacing.asp

一直以來都發現自己對cellpadding&cellspacing的定義是不夠清楚,所以很自然對padding&margin的定義也不是那麼的清楚。可是,我對於padding&margin的理解還是比cellpadding&cellspacing深入一點的,畢竟,padding&margin只不是用來對同一個物體自己本身的描述,padding(一個塊元素的內邊距,就是該元素中的內容到該元素內側邊框的距離),margin(一個塊元素的外邊距,就是該元素自己本身的邊框到父元素邊框的距離)。

 

預設情況下,表格中的儲存格是相互擠在在一起的。為了在你表格中的儲存格添加一些空間的話,可以使用cellpadding&cellspacing。

cellspacing —— 控制著兩個儲存格之間的距離,儘管是沒有官方預設值的,瀏覽器通常卻會使用一個預設值為2,即在瀏覽器中,cellspacing的值就是會預設為2。

 

cellpadding —— 控制儲存格中內容與儲存格內四周之間的距離,預設值是1。通常情況下,cellpadding比cellspacing可以更加的有效擴大表格內容。

 

原文連結:http://www.htmlcodetutorial.com/tables/index_famsupp_29.html

 

How to set cellspacing and cellpadding in css ?

http://stackoverflow.com/questions/339923/how-to-set-cellpadding-and-cellspacing-in-css

 

For controlling "cellpadding" in CSS, you can simply use padding on table cells. E.g. for 10px of "cellpadding":

td {     padding: 10px;}

For "cellspacing", you can apply the border-spacing CSS property to your table. E.g. for 10px of "cellspacing":

table {     border-spacing: 10px; border-collapse: separate;}

This property will even allow separate horizontal and vertical spacing, something you couldn‘t do with old-school "cellspacing".

Issues in IE <= 7

This will work in almost all popular browsers except for Internet Explorer up through Internet Explorer 7, where you‘re almost out of luck. I say "almost" because these browsers still support the border-collapseproperty, which merges the borders of adjoining table cells. If you‘re trying to eliminate cellspacing (that is, cellspacing="0") then border-collapse:collapse should have the same effect: no space between table cells. This support is buggy, though, as it does not override an existing cellspacing HTML attribute on the table element.

In short: for non-Internet Explorer 5-7 browsers, border-spacing handles you. For Internet Explorer, if your situation is just right (you want 0 cellspacing and your table doesn‘t have it defined already), you can use border-collapse:collapse.

table {     border-spacing: 0; border-collapse: collapse;}

 

[翻譯][HTML]CELLPADDING and CELLSPACING

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.