gpt4 book ai didi

css 设置 div 位置,没有 margin-top 和

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

如何设置 <div>没有 <br/> 的位置和 margintop ?例如margin-top: 40px

HTML:

<div id="page" class="div_page">
<div id="login" class="div_login">
asd
</div>
</div>

CSS:

<style>
div.div_login {
background-color:#EAEAEA;
height: 200px;
width: 400px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
</style>

最佳答案

一种方法是相对定位 div 并使用 top:40px

div.div_login {
background-color:#EAEAEA;
height: 200px;
width: 400px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
top:40px;
position:relative;
}

关于css 设置 div 位置,没有 margin-top 和 <br/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25212338/

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