【问题标题】::after in a <img> element unexpected result [duplicate]:在 <img> 元素中出现意外结果 [重复]
【发布时间】:2013-07-23 16:54:45
【问题描述】:

我有这个 CSS:

section#single-result > div > div.horizo​​ntal-scroll > div img { 高度: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;
}

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

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

【问题讨论】:

    标签: css image css-selectors


    【解决方案1】:

    :before和:afterpseudo-elements不能用IMG Tag,input tag

    MOre info

    您不能在 img in CSS

    上使用 :before 或 :after

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-22
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多