gpt4 book ai didi

html - 我正在为我的 留边距...但它不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 03:30:18 25 4
gpt4 key购买 nike

我正在尝试创建一个包含一些 <th> 的表格和`。

我想给我的第二个表头留一个边距,所以我的第二个 th 有一个类边距.

但它不起作用,我没有得到任何 margin 。

我这里有我的例子:

http://jsfiddle.net/xnwtqLsc/4/

HTML:

<body>
<table>
<th>Test Title 1</th>
<th class="margin">Test Title 2</th>
<th>Test Title 3</th>
<th>Test Title 4</th>
<tr>
<td>Test 1.1</td>
<td>Test 1.2</td>
<td>Test 1.3</td>
<td>Test 1.4</td>
</tr>
</table>
</body>

CSS:

body{
width:1000px;
background:#ccc;
}

table{
border-collapse: collapse;
}
table th{
color: #fff;
font-family: Arial;
font-size: 1.1em;
font-weight: bold;
background:red;
height:40px;
}
table th.margin{
margin-left:350px;
}

最佳答案

如果要使用 margin-left,还需要将 display: block 添加到 table th.margin 的 CSS 中,像这样:

table th.margin{
display: block;
margin-left: 350px;
}

尽管我建议您改用 padding-left:

table th.margin{
padding-left: 350px;
}

关于html - 我正在为我的 <th> 留边距...但它不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26435452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com