我想用 @Html.ActionLink
呈现一个按钮,但我需要在文本中包含我的应用程序字体。
使用此代码:
<span>
@Html.ActionLink(" Create New", "Create", null, new { @class = "btn btn-warning glyphicon glyphicon-plus-sign" })
</span>
我得到了按钮,但新建文本与字形字体系列一起出现。
将字形图标类放入范围中不会改变任何内容
最佳答案
您不应将 glyphicon 类添加到 a 标记。
来自 Bootstrap 网站:
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.
换句话说,按照您想要的方式工作的正确 HTML 是:<a href="#" class="btn btn-warning">test <span class="glyphicon glyphicon-plus-sign"></span></a>
这使得Html.ActionLink
helper 不合适。相反,你可以使用类似的东西:
<a href="@Url.Action("Action", "Controller")" class="btn btn-warning">
link text
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
</a>
关于asp.net-mvc - 带有字形图标和不同字体文本的 ASP.NET Actionlink,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26174013/