gpt4 book ai didi

css - 我有两个 div,我希望它首先出现在 html 中的第二个顶部,第二个 div 属性不能更改

转载 作者:行者123 更新时间:2023-11-28 03:22:55 25 4
gpt4 key购买 nike

我有两个 div 元素,我无法更改第二个 div 的属性。

我希望第一个 div 出现在 second div 之上,第二个 div 应该留在它后面。

.second{
height: 100px;
background: #000 !important;
padding: 0px !important;
margin: 0px !important;
display: block !important;
position: relative !important;
width: 100% !important;
float: right !important;
padding-top: 6px !important;
visibility: inherit !important}

.first{
/* what must be here? */
}
<div class="first">
attributes of this div can be changed
</div>

<div class="second">
attributes of this div cant be changed
</div>

最佳答案

使用 z-index 属性 + 相同的填充和 .second:

.first{
position: absolute;
z-index: 1;
padding-top: 6px;
}

codepen

关于css - 我有两个 div,我希望它首先出现在 html 中的第二个顶部,第二个 div 属性不能更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45125362/

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