gpt4 book ai didi

css - margin top 负值问题 css

转载 作者:太空宇宙 更新时间:2023-11-04 14:37:51 24 4
gpt4 key购买 nike

我在另一个 div 中有一个 div。我需要从容器 div 中拉出内部 div。我使用了以下代码。如果我在负值中使用 margin top,容器 div 也会随着内部 div 向上移动。对于某些对齐问题,我无法使用 position absolute

代码:

    <div style="background-color:#999999; width:150px; height:300px;">
<div style="position:relative; width:100px; height:100px; background-color:#006633; margin-top:-50px;"></div>
</div>

如何仅通过相对位置实现这一点?

最佳答案

代替 margin-top 使用 top

demo fiddle

top: -10px;

关于css - margin top 负值问题 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18605852/

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