Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS text-indent - remove text but not content added using :after

I am using a slider that I can't modify the navigation text (next / previous) but I would like to replace the text with an arrow

I have added the arrows with the following 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";
}

If I add the following CSS the arrow and text disappears

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

I want to keep the arrow but remove the text, is this possible?

THe HTML structure for the navigation is:

<ul class="hero-carousel-nav">
    <li class="prev">
        <a href="#">
          Previous
        </a>
    </li>
</ul>
like image 459
Gareth Gillman Avatar asked May 24 '14 22:05

Gareth Gillman


People also ask

How do you remove text-indent in CSS?

The padding-left:0 is used to remove indentation (space) from left.

How do I remove text from an element in CSS?

By using text-indent: -999px; or a similar method, the text is still there — just not visually there. Use display:none , and the text is gone.

How do you indent text in CSS?

You can use the CSS text-indent property to indent text in any block container, including divs, headings, asides, articles, blockquotes, and list elements. Say you want to indent all div elements containing text on a page to the right by 50px. Then, using the CSS type selector div, set the text-indent property to 50px.

How do you use ellipsis CSS?

The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string. Syntax: text-overflow: clip|string|ellipsis|initial|inherit; Property Values: All the properties are described well with the example below.


1 Answers

By defaut, pseudo element are inline element and follow text-indent. If you make it, float or a block boxe , it will stay in view. Then you still need to reset to it text-indent to 0; it can be then :

#carousel .hero-carousel-nav .next:after {
 font-family: "Glyphicons Halflings";
 color:#FFF;
 content: "\e080";
float:left;/* or display:block */
text-indent:0;
}
like image 80
G-Cyrillus Avatar answered Sep 24 '22 16:09

G-Cyrillus