2016-03-18 57 views
0

我添加了一个背景图片,它在页面中不可见。背景图片不可见Css

这是我的尝试:

的CSS:

div{ 


    background: url(http://patentimages.storage.googleapis.com/CN103289961A/CN103289961AD00172.png) no-repeat center center fixed; 
     -webkit-background-size: contain; 
     -moz-background-size: contain; 
     -o-background-size: contain; 
     background-size: contain; 
     vertical-align: middle; 
     background-position: center; 
    } 

Demo Link

回答

4

这是因为DIV没有措施的宽度和高度固定或定义。

background: url(http://patentimages.storage.googleapis.com/CN103289961A/CN103289961AD00172.png) no-repeat center center fixed; 
    -webkit-background-size: contain; 
    -moz-background-size: contain; 
    -o-background-size: contain; 
    background-size: contain; 
    vertical-align: middle; 
    background-position: center; 
    width: 500px; 
    height: 500px; 
} 

工作link

+0

谢谢你,它工作正常,但我有文字图像,其渐渐模糊。 https://jsfiddle.net/8sjjxp0e/4/ –

+0

当然,这种行为是因为当你使用背景大小的包含属性时,它会尝试适应这个度量,然后图像变得模糊。 – WakeupMorning

+0

任何工作链接,以摆脱模糊。 –