gpt4 book ai didi

html - 位置 div margin top 30px 但使用 margin auto 将 margin 保持在中心?

转载 作者:行者123 更新时间:2023-11-28 08:11:17 26 4
gpt4 key购买 nike

我在让我的 div 将我的页面向下移动 30 像素/在我的 div 顶部添加边距 30 像素时遇到问题。我的 div 使用 margin auto 在页面中心对齐。

然而,当我尝试添加这行代码时:边距:30px auto 0 auto;

没有显示上边距?请有人告诉我我做错了什么吗?谢谢,

#content_other{
width:790px;
height: auto;
font-family: 'Arial Narrow', Tahoma, Verdana, Arial Narrow, sans-serif;
font-size:12px;
margin: 30px auto 0 auto;
position:relative;
overflow: hidden;
padding:20px;
background:#fff;
border: 1px solid #999;
-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
-moz-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;


}

html:

<div id="content_other">

<html form here>

</div>

最佳答案

您的代码没有任何问题。看看这个JSFiddle .边距添加到顶部我使用了这个 HTML

<div id="content_other">
<form>
<input type="text" />
</form>
</div>

关于html - 位置 div margin top 30px 但使用 margin auto 将 margin 保持在中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29255612/

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