对于为什么这个简单的例子没有显示我的背景图像但我就是看不到它,我敢肯定有一个简单得可笑的答案。我希望看到图像两次,一次是图像使用类,一次是直接引用图像。
思想
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
.chkCombo {
background: transparent url(http://cache.siliconvalley-codecamp.com/Images/silicon-valley-code-camp.png);
}
</style>
</head>
<body>
<div class="x">
<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="chkCombo">
</div>
<hr />
<div class="x">
<img src="http://cache.siliconvalley-codecamp.com/Images/silicon-valley-code-camp.png" />
</div>
</body>
</html>
最佳答案
通过为图像添加高度和宽度并将其设置为 display: block;
图像将出现。
这是固定的 fiddle
顺便说一下,我没有看到 base64 图像的效果,您使用它并在同一元素上使用带有背景图像的类。
关于html - 背景图片用简单的 css 让我失望,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18578262/