【发布时间】:2014-07-16 18:15:30
【问题描述】:
我试图在 html 中的图像之后放置伪类,但它不起作用。这就是我所做的:
<img src="image.png" class="item-portfolio" alt="portfolio item">
CSS
.item-portfolio img:after{
content: url(images/shadow.png) no-repeat;
position: absolute;
right: 8px;
top: 0;
}
.item-portfolio p:before{
content: url(images/shadow.png) no-repeat;
display: block;
position: absolute;
left: 6px;
top: 0;
}
是否可以在图像之后设置此图像?
【问题讨论】:
-
括在
span? -
你的意思是
<span><img src="image.png" class="item-portfolio" alt="portfolio item"></span>? -
@user3699634:是的,并将之前和之后放在
span上。大致像this。 -
你的例子很好,但在我的文件中它不起作用;(