Elegance - Fontawesome in custom menu items?

Re: Elegance - Fontawesome in custom menu items?

by Dimo Dimov -
Number of replies: 8

Hi Zac,

Did you find a way to add "fa" icons to the custom menu?

Average of ratings: Useful (1)
In reply to Dimo Dimov

Re: Elegance - Fontawesome in custom menu items?

by Robin Leung -

Hi Zac,
I'd be happy to know too if you have found a solution.

Thanks,

Robin

In reply to Robin Leung

Re: Elegance - Fontawesome in custom menu items?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

You should be able to do this for the top menubar using CSS.

.navbar .nav li:nth-child(2) a:before {
  content: "\f0f4";
  font-family: FontAwesome;
  margin: 0 3px;
}
.navbar .nav li:nth-child(3) a:before {
  content: "\f0f5";
  font-family: FontAwesome;
  margin: 0 3px;
}
.navbar .nav li:nth-child(4) a:before {
  content: "\f0f6";
  font-family: FontAwesome;
  margin: 0 3px;
}

You would need to choose which icons you wanted though as the example given above is random.

Cheers

Mary

Average of ratings: Useful (3)
In reply to Mary Evans

Re: Elegance - Fontawesome in custom menu items?

by Robin Leung -

Hi Mary,

Thanks, this works with the exception that it also displays the icon for submenu's as well. So if I'm using nth-child(2), for all second items on the sub-menu it would display it as well.

Is there a workaround to only display it on the menu's but not sub-menus?

Thanks,

Robin

In reply to Robin Leung

Re: Elegance - Fontawesome in custom menu items?

by Robin Leung -

Never mind. Solved my own problem using the greater than sign. smile 

.navbar .nav > li:nth-child(3) a:before {
  content: "\f0f5";
  font-family: FontAwesome;
  margin: 0 3px;
}

In reply to Robin Leung

Re: Elegance - Fontawesome in custom menu items?

by Robin Leung -

I do have another question, might be an easy one for you to answer. But hard for me.

I want a space between text and the icon. How can I do that easily?

Thanks.

Attachment 2015-04-15_17-32-01.png
In reply to Robin Leung

Re: Elegance - Fontawesome in custom menu items?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Increase the margin from 3px to 5px

or remove the one I added margin: 0 3px; and use
margin-right: 5px;

instead.

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Trả lời: Re: Elegance - Fontawesome in custom menu items?

by Dinh tuan -

Hi Mary,


I use theme's CLEAN and I customize CSS following you guide. But Menu's Icons don't show.

I think It is error about font: FontAwesome. Can you guide me to config CSS?

Thanks.

In reply to Dinh tuan

Re: Trả lời: Re: Elegance - Fontawesome in custom menu items?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi,

If you have not added FontAwesome to your theme then it will not work as you need to add the font file first!

So download the font from HERE

Next read how to add the font in this Moodle tutorial: How to add custom fonts in a theme.

As well as adding the font files for FontAwesome you will also need to add the CSS for those fonts too.

The CSS in this case comes with the downloaded files.

Cheers

Mary