【问题标题】:CSS text-indent - remove text but not content added using :afterCSS text-indent - 删除文本但不使用 :after 添加的内容
【发布时间】:2014-05-24 22:09:36
【问题描述】:

我使用的滑块无法修改导航文本(下一个/上一个),但我想用箭头替换文本

我添加了带有以下 css 的箭头:

#carousel .hero-carousel-nav .prev a:after {
 font-family: "Glyphicons Halflings";
 color:#FFF;
 content: "\e079";
}
#carousel .hero-carousel-nav .next:after {
 font-family: "Glyphicons Halflings";
 color:#FFF;
 content: "\e080";
}

如果我添加以下 CSS,箭头和文本就会消失

#carousel .hero-carousel-nav .prev a {
 text-indent:-9999px;
}

我想保留箭头但删除文字,这可能吗?

导航的 HTML 结构是:

<ul class="hero-carousel-nav">
    <li class="prev">
        <a href="#">
          Previous
        </a>
    </li>
</ul>

【问题讨论】:

  • 让你的伪浮动并将 text-indent 重置为 0;

标签: css text-indent


【解决方案1】:

默认情况下,伪元素是inline 元素并跟随text-indent。 如果你成功了,float 或 block boxe ,它将保持在视野中。 然后你仍然需要重置它text-indent到0; 可以这样:

#carousel .hero-carousel-nav .next:after {
 font-family: "Glyphicons Halflings";
 color:#FFF;
 content: "\e080";
float:left;/* or display:block */
text-indent:0;
}

【讨论】:

    【解决方案2】:

    你可以试试这样的:http://jsfiddle.net/sandro_paganotti/HupTL/

    div{
        position: relative;
        text-indent: -9000px;
    }
    div:after{
        content: 'hi!';
        display: block;
        position: absolute;
        text-indent: 0;
        top:0;
        left:0;
        right:0;
        bottom:0;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-26
      • 2021-10-12
      • 1970-01-01
      • 2016-06-22
      • 1970-01-01
      • 2019-06-27
      • 2012-04-27
      相关资源
      最近更新 更多