位置:绝对,宽度:未知。如何中心div [英] Position: absolute, width: unknown. How to center div
问题描述
我需要将div的中心放在此页面上的图片滑块上:
http:// dharman.eu/daftPunk/
我搜索了一个方法来做这个SO,我发现这个线程:
div标签的位置中心,宽度未知高级
我应用了给定的解决方案,但结果不是我预期的。
任何人都可以告诉我这里的问题是什么?
$ b $编辑:
这是发生在FF,在Chrome的div是一路向右。 / div>
尝试这个CSS #sliderDots
:
#sliderDots {
position:relative;
bottom:40px;
display:inline-block;
background-color:whiteSmoke;
border-radius:15px;
box-shadow:0 0 10px 3px,0 0 10px 0#888 inset;
padding:10px 10px 10px 20px;
}
在IE,FF和Chrome中工作正常(位置更改为 relative
,底部为 40px
)
I need to center the div with the dots on the image slider on this page: http://dharman.eu/daftPunk/
I have searched for a way to do this on SO and I found this thread: Position center of div tag, which width is unknown advanced
I applied the solution given there but the result is not as I expected. The div looks to be centered a bit more to the right than it should be.
Can anyone tell me what could be the issue here?
EDIT: This is happening in FF, in Chrome div is all the way to the right.
Try this CSS for #sliderDots
:
#sliderDots {
position: relative;
bottom: 40px;
display: inline-block;
background-color: whiteSmoke;
border-radius: 15px;
box-shadow: 0 0 10px 3px, 0 0 10px 0 #888 inset;
padding: 10px 10px 10px 20px;
}
Works fine in IE, FF and Chrome (position changed to relative
and bottom to 40px
)
这篇关于位置:绝对,宽度:未知。如何中心div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!