在CSS中,要設置tr
元素的上下邊距,可以使用padding
屬性。padding
屬性用于設置元素的內邊距,即元素邊框與其中內容之間的空間,在tr
元素中,你可以為上下左右四個方向分別設置不同的內邊距。
要為tr
元素的上方設置10像素的內邊距,下方設置20像素的內邊距,可以使用以下CSS代碼:
tr { padding-top: 10px; padding-bottom: 20px; }
這段代碼將為所有tr
元素應用樣式,使其上方內邊距為10像素,下方內邊距為20像素,你可以根據(jù)需要調整這些值。
如果你想為特定的tr
元素設置不同的上下邊距,可以使用類(class)或ID來區(qū)分不同的元素。
.special-row { padding-top: 30px; padding-bottom: 40px; }
在HTML中,為需要特殊樣式的tr
元素添加class="special-row"
:
<table> <tr class="special-row"> <!-- 表格內容 --> </tr> <tr> <!-- 表格內容 --> </tr> <tr class="special-row"> <!-- 表格內容 --> </tr> </table>
這樣,只有帶有class="special-row"
的tr
元素會有特殊的上下邊距樣式。
版權聲明:除非特別標注,否則均為本站原創(chuàng)文章,轉載時請以鏈接形式注明文章出處。