【发布时间】:2014-01-15 13:39:39
【问题描述】:
对不起,如果这个问题已经存在,但我没能找到它。我想知道为什么 img:after 在 CSS 中不起作用。我尝试将 img 的显示设置为阻止,什么不是,但它每次都拒绝工作......有什么想法吗?我正在尝试在图像之后放置背景图像(用于老式阴影),但仅当我将图像放置在 div/span 中时它才有效。
这就是我一直试图运行的:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Exercise2</title>
<link rel="stylesheet" type="text/css" href="exercise2.css">
</head>
<body>
<div id="container">
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSJxP3c9QZ--VxiX0M1p9shvBa0KDLGjTjlqC3V4ygH_zA6vn-Bvw">
</div>
</body>
</html>
CSS:
#container {
width: 100%;
}
img {
display: block;
}
.shadow:after {
display: block;
position: absolute;
right: 0;
top: 0;
top: 10%;
content: "";
height: 90%;
width: 6px;
background: url(pictures/shadow_side.png) repeat-y 0% 0%;
}
【问题讨论】:
-
这里回答(按规范)......stackoverflow.com/questions/11903273/…
-
大部分浏览器不支持。根据一个类似的问题:stackoverflow.com/questions/5843035/…
-
你连
.shadow都不用?