MyBB Community Forums

Full Version: Fa icons next to some link/text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

so i managed to create a neat drop down list. But when i tried adding font awesome icons next to it, it kinda didn't work.
Could some explain me how i would get the fa icons next to the links on the drop down list? Maybe also with the codes i added below.

I tried adding e.g. <i class="fa fa-comments"> right before the usercp or before the "Settings", but it doesn't get at the same line.

The required part in headerinclude is included:
<link href='//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' rel='stylesheet' type='text/css'>

[Image: 691a37fc0f857f4d0272d9c2e3268dd0.gif](As you can see the icon is at the top left)


How i made the drop down:

Html:
<div class="dropdown">
  <button onclick="myFunction()" class="dropbtn">Settings</button>
<div id="myDropdown" class="dropdown-content">
  	<i class="fa fa-comments"></i><a href="{$mybb->settings['bburl']}/usercp.php" class="usercp" >Control Panel</a>
	<a href="#" onclick="MyBB.popupWindow('{$mybb->settings['bburl']}/misc.php?action=buddypopup&modal=1', null, true); return false;">{$lang->welcome_open_buddy_list}</a>
    <a href="{$mybb->settings['bburl']}/search.php?action=getnew">{$lang->welcome_newposts}</a>
    <a href="{$mybb->settings['bburl']}/search.php?action=getdaily">{$lang->welcome_todaysposts}</a>
    <a href="{$mybb->settings['bburl']}/private.php">{$lang->welcome_pms}</a> {$lang->welcome_pms_usage}
</div>

Css:
.dropbtn {
	-moz-box-shadow:inset 47px 50px 0px 15px #F5F5F5;
	-webkit-box-shadow:inset 47px 50px 0px 15px #F5F5F5;
	box-shadow:inset 47px 50px 0px 15px #F5F5F5;
	background-color:#ebebeb;
	-moz-border-radius:2px;
	-webkit-border-radius:2px;
	border:1px solid #F9DD54;
	display:inline-block;
	cursor:pointer;
	color:#666666;
	font-family:Arial;
	font-size:15px;
	padding:2px 20px;
	text-decoration:none;
	margin: -3px 10px 0 0;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    overflow: auto;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown a:hover {background-color: #F9DD54}

.show {display:block;}

Jscript:
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
    document.getElementById("myDropdown").classList.toggle("show");
}

// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
  if (!event.target.matches('.dropbtn')) {

    var dropdowns = document.getElementsByClassName("dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {
        openDropdown.classList.remove('show');
      }
    }
  }
}
</script>
Thanks for any help.
The format can be like this;

<a href="{$mybb->settings['bburl']}/usercp.php" class="usercp" ><i class="fa fa-comments" aria-hidden="true"></i>&nbsp;Control Panel</a>

class="usercp" and the other classes on the nav links are no longer needed.
Thank you very much!