上图
代码为:
<!DOCTYPE html>
<html>
<head>
</head>
<style type="text/css">
// 将背景设置蓝色
body {
background-color: blue;
}
#xx {
margin-top: 100px;
margin-left: 500px;
}
</style>
<body>
//设置图片长宽 赋上id
<img id="xx" style=" width: 200px; height: 200px; ">
</body>
</html>
解决方案
<!DOCTYPE html>
<html>
<head>
</head>
<style type="text/css">
body {
background-color: blue;
}
#xx {
margin-top: 100px;
margin-left: 500px;
}
/*方案在这*/
img[src=""],img:not([src]){
opacity:0;
}
</style>
<body>
<img id="xx" style=" width: 200px; height: 200px; ">
</body>
</html>