I am having a problem getting the icon to appear directly after a list item in a <ul>
using font awesome and :after
.
The <li>
with the active class should have the icon after it but when another <ul>
is added in before closing the list item, it's puts the icon after the entire secondary list.
<div id="thirdLevMenu"> <ul> <li class="active">Integrated Coastal Watershed Management Plans <ul> <li><a href="http://design-irwmp3.migcom.com/app_pages/view/7931">Russian River Integrated Coastal Watershed Management Plan</a></li> <li><a href="http://design-irwmp3.migcom.com/app_pages/edit/http:/www.goldridgercd.com/watersheds/salmoncreekplan.html" target="_blank">Salmon Creek Coastal Watershed Management Plan</a></li> <li><a href="http://design-irwmp3.migcom.com/app_pages/edit/http:/www.mattole.org/plan" target="_blank">Mattole Coastal Watershed Management Plan</a></li> <li><a href="http://design-irwmp3.migcom.com/app_pages/edit/http:/www.trinidad.ca.gov/documents-library/category/30-icwmp.html" target="_blank">Trinidad-Westhaven Coastal Watershed Management Plan</a></li> </ul> </li> </ul> </div>
I can't for the life of me figure out what I am doing wrong.
Here's my jsfiddle
You just have to add the following CSS to your after or before element: font: normal normal normal 14px/1 FontAwesome; content: '\f042'; Here the content is the icon you want to add. Just copy the Unicode of the icon from the FA website and paste it in the content with a \ prefix.
The font-awesome icon can be placed by using the fa prefix before the icon's name. Example: In this example, we will take a form where the input field is necessary. After that, we will place the font-awesome icon inside the input field. We will use the CDN link to use the font-awesome icons.
To insert an icon, add the name of the icon class to any inline HTML element. The <i> and <span> elements are widely used to add icons. All the icons in the icon libraries below, are scalable vector icons that can be customized with CSS (size, color, shadow, etc.)
As I mentioned in the comment:
"When you add that second <ul>
inside the top <li>
, that entire inside list becomes part of the parent list item. It's doing exactly what you're telling it too, it's putting the arrow directly after the <li>
."
If you want the icon to go after the text reading "Integrated Coastal Watershed Management Plans" instead, add a span around that title and tweak your CSS to add the :after
pseudo element to that span instead of the entire <li>
.
HTML
<li class="active"> <span class = "title">Integrated Coastal Watershed Management Plans</span> ... </li>
CSS
#thirdLevMenu ul li.active .title:after{ content: '\f0da'; font-family: FontAwesome; font-weight: normal; font-style: normal; margin:0px 0px 0px 10px; text-decoration:none; }
Here's an updated fiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With