作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我想这样做:
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/
我是一名优秀的程序员,十分优秀!