在一个div中居中一个图像 [英] Centering an image within a div
本文介绍了在一个div中居中一个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经将 div
中的图片边框设为无。我现在想要在其包含的div中心的那个图像。我尝试使用 margin:0 auto;
但是没有工作。
I have already set the border of an image within a div
to be none. I now want to center that image within its containing div. I have tried using the margin: 0 auto;
but that did not work.
我相信我可以俯瞰一些愚蠢的,但我想征求stackoverflow社区的帮助,所以这不需要我一个小时盯着屏幕弄清楚。非常感谢。
I am sure I am overlooking something stupid but I would like to enlist the help of the stackoverflow community so this doesn't take me an hour of staring at the screen to figure out. Thanks a lot.
<body>
<div id="wrapper">
<div id="banner">
<img src="logo3.png"/>
<!--<img src="kslf_logo.png"/>
<img src="logo2.png" title="Katie Samson Lacrosse Festival Logo"/>-->
<div id="social_network">
<a href="#" target="_blank" title="Check out the Facebook Page!">Facebook</a>
</div>
</div>
</div>
</body>
这里是CSS ...
Here is the CSS...
#banner {
height: 100px;
width: 960px;
padding-bottom: 10px;
}
#banner img {
border: none;
margin: 0 auto;
}
推荐答案
尝试设置图像显示属性到
阻止
:
banner {
height: 100px;
width: 960px;
padding-bottom: 10px;
}
banner img {
border: none;
display: block;
margin: 0 auto;
}
这篇关于在一个div中居中一个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文