1

我有这个CSS:

section#single-result > div > div.horizo​​ntal-scroll > div img { height: 200px; 右边距:4px;位置:相对;}

布局或多或少是这样的:

<div class="horizontal-scroll">
     <div>
         <img alt="" src="path.jpg">
             <img alt="" src="path.jpg">
             <img alt="" src="path.jpg">
     </div>
</div>

问题是我想在第一张图片上放一个箭头,所以我正在尝试使用 after 伪元素

section#single-result > div > div.horizontal-scroll > div img:first-child:after {
    background: none repeat scroll 0 0 red;
    content: " ";
    display: block;
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index:9999;
}

但这甚至不会在它上面显示一个红色块,

知道我错过了什么吗?那是:使用 img 后不能按预期工作吗?

4

1 回答 1

0

:before并且:after pseudo-elements不能使用IMG Taginput tag

更多信息

你不能在 CSS 中使用:beforeor :afteron img

于 2013-07-23T08:49:29.153 回答