You can use the pseudo-element before or after and apply some CSS to it. There are different ways. You can add both before and after , and rotate and place each of them in one of the columns. A simpler solution is to add two borders only to the before element and rotate it with transform: rotate .
Scroll down for another solution that uses the actual item instead of pseudo-elements
In this case, I added arrows in the form of markers in the list and used em sizes to make their size the appropriate font for the list.
ul { list-style: none; } ul.big { list-style: none; font-size: 300% } li::before { position: relative; content: ""; display: inline-block; width: 0.4em; height: 0.4em; border-right: 0.2em solid black; border-top: 0.2em solid black; transform: rotate(45deg); margin-right: 0.5em; } li:hover { color: red; } li:hover::before { border-color: red; }
<ul> <li>Item1</li> <li>Item2</li> <li>Item3</li> <li>Item4</li> </ul> <ul class="big"> <li>Item1</li> <li>Item2</li> <li>Item3</li> <li>Item4</li> </ul>
Of course, you do not need to use before or after , you can apply the same trick to a normal element. For the list above, this is convenient because you do not need additional markup. But sometimes you may need (or need) markup. You can use a div or span for this, and I even saw that people even recycle the i element for βiconsβ. So the markup may look like below. Whether using an <i> for this is correct is controversial, but you can also use a span for this to be safe.
i { display: inline-block; font-style: normal; position: relative; } i.arrow { width: 0.4em; height: 0.4em; border-right: 0.2em solid black; border-top: 0.2em solid black; transform: rotate(45deg); }
And so you can have an <i class="arrow" title="arrow icon"></i> in your text. This arrow is <i class="arrow" title="arrow icon"></i> used to be deliberately lowered slightly on request. I removed that for the general public <i class="arrow" title="arrow icon"></i> but you can uncomment the line with 'top' <i class="arrow" title="arrow icon"></i> to restore that effect.
If you're looking for more inspiration, be sure to check out this amazing Nicolas Gallagher CSS clean badge library. :)
GolezTrol Dec 15 '14 at 20:17 2014-12-15 20:17
source share