【发布时间】:2014-12-31 20:37:01
【问题描述】:
我决定暂时删除该表,只使用 DIVS。 (更新)
这是我正在尝试的一个持续的个人计划。我正在学习使用html和css。我想知道为什么无论我尝试做什么来在表中的每一行之间创建空间它都不会改变。我尝试了边框间距...边框折叠...填充但没有任何反应。
表格在页面的左侧。
CSS:
tr.spaceUnder > td
{
margin-bottom: 5px;
display: block
}
table {
border-spacing: 10px;
border-collapse: separate;
}
td {
padding: 20px;
}
/* Formating for left sidebar of information */
#sidebar {
"background-color: #eee;
height: 200px;
width:350px;
float:left;
margin-top: 30px;
margin-left: 30px;
border: 1px solid black;
border-radius: 5px;
}
HTML代码
<div id ="sidebar">
<table style = "width:350px; height: auto;">
<tr class = "spaceUnder">
<td>
<div><b> Things to take into account: </b></div>
<div>
<p>
When creating a website, don't forget about structuring.
If you can't get the objects to stop moving then your logic
must be wrong.
</p>
</div>
</td>
</tr>
<tr class = "spaceUnder">
<div><b> Things to take into account: </b></div>
<div>
<p>
When creating a website, don't forget about structuring.
If you can't get the objects to stop moving then your logic
must be wrong.
</p>
</div>
</td>
</tr>
</table>
</div> <!-- end sidebar -->
仅供参考-文本的中间容器应该在正确的下方。 - 这将是我的下一个问题,因为我也已经尝试解决了好几个小时。
【问题讨论】:
-
您的 CSS 中似乎还有一个小错字:
"background-color: #eee;的开头有一个 "。 -
另外,为了它的价值...我建议你学习使用 Div 和 CSS 而不是表格来构建 Web 布局。用于布局的表格是一种非常过时的网络构建方式,它不会给你任何正义。这就像在Model T 中学习开车一样。起初它可能看起来令人生畏(我们都去过那里),但你会惊讶地发现你会以多快的速度开始围绕它。另外,我们在这里为您提供帮助! :)
-
明确说明问题所在。 “行不通”不是问题描述。请勿包含与所示代码实际不对应的屏幕截图。
-
好的,谢谢你告诉我我的错字。我会解决这个问题,看看会发生什么。一旦我尝试了一些示例,我将看看是否有比表格更好的方法。起初我没有桌子,但间距也不起作用,这就是我选择桌子的原因。
-
Jukka K. Korpela:我展示的图像与我的代码完全相关。我在问题的第一段中说代码涉及左侧的框。所以我很困惑为什么你说我不清楚。我说过间距命令也不起作用。