如何在 div 中居中(背景)图像? [英] How to center a (background) image within a div?
本文介绍了如何在 div 中居中(背景)图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 div 中将背景图像居中?我几乎尝试了所有方法 - 但没有成功:
Is it possible to center a background image in a div? I have tried just about everything - but no success:
<div id="doit">
Lorem Ipsum ...
</div>
//CSS
#doit { background-image: url(images/pic.png); background-repeat: none; text-align: center; }
这可能吗?
推荐答案
#doit {
background: url(url) no-repeat center;
}
这篇关于如何在 div 中居中(背景)图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文