简体   繁体   English

表格内的html间距

[英]html spacing inside the table

how can i increase the space in this table "Row 1, cell 1"? 如何增加此表“行1,单元格1”中的空间?

 <html>
 <table border="1">
 <tr>
 <td>Row 1, cell 1</td>
 <td>Row 1, cell 2</td>
 </tr>
 </table>  
 </html>

pls check here for the image: http://img227.imageshack.us/img227/6166/htmln.png 请在此处检查图像: http : //img227.imageshack.us/img227/6166/htmln.png

is this correct: 这个对吗:

 <table border="1" td.my-cell { padding:100px; }>
<tr>
<td class="my-cell">Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>  

You can either use cellpadding or using css 您可以使用cellpadding或使用CSS

.cellpadding {
   padding-left: 5px;
   padding-right: 5px;
}

<td class="cellpadding">Row 1, cell 1</td>

EDIT Your edited post is wrong....do this: 编辑您编辑的帖子是错误的。...执行以下操作:

<table border="1">
    <tr>
        <td style="padding-left: 5px; padding-right: 5px;">Row 1, cell 1</td>
        <td>Row 1, cell 2</td>
    </tr>
</table>

You can add a class to that specific cell and then use that class-name to apply css: 您可以将一个类添加到该特定的单元格,然后使用该类名称来应用css:

.larger {
height: 2em;
width: 4em;
padding: 2em;
}

<!-- rest of table -->
<td class="larger">Row 1, cell 1</td>
<!-- rest of table -->

Or you could use specific style-rules to apply a particular style: 或者,您可以使用特定的样式规则来应用特定的样式:

tr td:first-child /* selects the first td within a tr */

Though this would apply to the first td of every row. 尽管这将适用于行的第一个td

elaborate on "space"? 阐述“空间”? you can add padding to the td if thats what you mean by "space" 您可以在td中添加填充,如果那是“空格”的意思

table td { padding:5px; }

if you just want that cell bigger, add a calss 如果您只想让该单元格更大,请添加一个calss

table td.my-cell { padding:5px; }

<td class="my-cell">Row 1, cell 1</td>

or do you mean 还是你的意思是

<td> Row 1, cell1 </td> <td>第1行,单元格</td>

you can increase the space between words like this: 您可以像这样增加单词之间的间距:

table td { word-spacing: 20px; /* adjust */ }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM