如何中心的div内(背景)的形象? [英] How to center a (background) image within a div?

查看:117
本文介绍了如何中心的div内(背景)的形象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在一个div居中背景图像?我曾尝试只是一切 - 但没有成功:

 < D​​IV ID =DOIT>
  Lorem存有...
< / DIV>// CSS
#doit {背景图像:网址(图像/ pic.png);背景重复:无;文本对齐:中心; }

这可能吗?


解决方案

  #doit {
    背景:网址(URL)不重复中心;
}

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; }

Is this possible?

解决方案

#doit {
    background: url(url) no-repeat center;
}

这篇关于如何中心的div内(背景)的形象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆