Wednesday 20 September 2017

ASP.NET Actionlink with glyphicon and text with different font

You should not add the glyphicon class to the a-tag.
From the Bootstrap website:
Don't mix with other components Icon classes cannot be directly combined with other components. They should not be used along with other classes on the same element. Instead, add a nested <span> and apply the icon classes to the <span>.
Only for use on empty elements Icon classes should only be used on elements that contain no text content and have no child elements.
In other words the correct HTML for this to work the way you want would be: <a href="#" class="btn btn-warning">test <span class="glyphicon glyphicon-plus-sign"></span></a>
This makes the Html.ActionLink helper unsuitable. Instead you could use something like:
<a href="@Url.Action("Action", "Controller")" class="btn btn-warning">
    link text 
    <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
</a>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive