我在网页设计中有一个坏习惯,我试图解决这个问题(我不使用表格布局;-))。
我只想知道降低div的好方法。
例如:
<div class="container">
<p>
something like this
</p>
</div>
我只是想把div 放下来。
我喜欢以正确的方式做事,但做起来要快得多
<br /><br /><br /><br />
这很丑陋,我需要你的帮助来避免这种情况
提供边距顶部样式以降低div
<div class="container" style="Margin-Top:25px;">
<p>
something like this
</p>
</div>
演示小提琴
您提供的保证金越多,它将相应地降低使用:)
在你的
css中添加
.container { margin-top: 30px; }
您可以使用
margin-top
或position:absolute and then top:some value
或padding-top
演示
使用这些 CSS 中的任何一个
1.
.container{
margin-top:50px;
}
阿拉伯数字。
.container{
position:absolute;
top:50px;
}
3.
.container{
padding-top:50px;
}
在 CSS 文件中添加以下内容:
.container {
margin-top: 20px;
}
或者,如果要在容器内向下移动 p 标记,请执行以下操作之一:
.container p {
margin-top: 20px;
}
或
.container {
padding-top: 20px;
}