gpt4 book ai didi

css - 如何做 margin : 0 auto 0 auto minus a few pixels with CSS?

转载 作者:技术小花猫 更新时间:2023-10-29 11:16:12 25 4
gpt4 key购买 nike

我想这样做:

margin: 0 auto 0 auto;

所以它 float 到中心,但我想将 div 向左移动 100px 本质上是这样

margin: 0 auto 0 [auto minus 100px];

所以它在中心左侧 100px。

我如何使用 CSS 做到这一点?


注意:

这个 div 覆盖在另一个 div 之上。我不能将它放在另一个更大的 div 中。

<style>
#one {
width: 100px;
margin: ?
}
</style>
<div id="one">
sdgdgffdsg
</div>

更新:已解决

GGG 在评论中给了我解决方案。

position: absolute;
left: -100px;
margin: 0 auto;

最佳答案

居中 使用 margin: 0 auto;
并使用 position: relative; 向移动;左:-100px;

position: relative;
margin: 0 auto;
left: -100px;

关于css - 如何做 margin : 0 auto 0 auto minus a few pixels with CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10324411/

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