小智 167
就像img标签是一个内容元素一样
img {
content:url(http://example.com/image.png);
}
Run Code Online (Sandbox Code Playgroud)
Ali*_*der 73
#divID {
background-image: url("http://imageurlhere.com");
background-repeat: no-repeat;
width: auto; /*or your image's width*/
height: auto; /*or your image's height*/
margin: 0;
padding: 0;
}
Run Code Online (Sandbox Code Playgroud)
cle*_*tus 47
不,没有.您可以指定背景图像,但这不是一回事.
不.您可以获得的最接近的是设置背景图像:
<div id="myimage"></div>
#myimage {
width: 20px;
height: 20px;
background: white url(myimage.gif) no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
在尝试了这些解决方案后,我仍然不满意,但是在本文中找到了解决方案,并且该解决方案可以在Chrome,Firefox,Opera,Safari,IE8 +中运行
#divId {
display: block;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: url(http://notrealdomain2.com/newbanner.png) no-repeat;
width: 180px; /* Width of new image */
height: 236px; /* Height of new image */
padding-left: 180px; /* Equal to width of new image */
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
373250 次 |
| 最近记录: |