I've been trying to do some kind of navbar with MaterializeCSS with 3 links, each one of 33% width of the navbar, and I want to center the text inside the links (even the icons)
If I don't put left or right classes, the text and the icon doesn't stay in the same line... But if I put left class to the icon then it floats to the left, therefore given that the navbar is width:100%, the space between the icon and the text is too much.
Here is the HTML
<div id="secondary-navbar"><nav>
<div class="nav-wrapper">
<ul>
<li>
<a href="#!">
<i class="material-icons left">event</i>Calendario
</a>
</li>
<li>
<a href="#!">
<i class="material-icons left">location_on</i>Mapa
</a>
</li>
<li>
<a href="#!">
<i class="material-icons left">apps</i>Galería
</a>
</li>
</ul>
</div>
</nav></div>
And the CSS
#secondary-navbar nav
{
background:#ffffff;
}
#secondary-navbar nav .nav-wrapper ul li a
{
font-size:1.2em;
}
#secondary-navbar nav .nav-wrapper ul li a .material-icons
{
font-size:1.2em;
margin-right:0.2em;
}
#secondary-navbar nav .nav-wrapper ul li a,
#secondary-navbar nav .nav-wrapper ul li a .material-icons
{
color:#06207d;
}
#secondary-navbar nav .nav-wrapper ul li
{
width:33%;
}
#secondary-navbar nav .nav-wrapper ul li:nth-child(3)
{
width:34%;
}
Here is a jsfiddle, I tried with inline-block to the icon, but then then navbar gets more than 56px height... https://jsfiddle.net/4aednm5d/
Do you have any idea about how to solve this?
I generally use this:
.icon-align {
vertical-align: text-bottom;
}
<i class="material-icons md-18 icon align">check_circle</i>Auto Accepted</div>`
Use
text-align: center;
for aligning text and icons in the center of the parent.
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