我想提出一个按钮与@ Html.ActionLink,但我需要有我的应用程序字体在文本中。
有了这个代码:
<span> @Html.ActionLink(" Create New","Create",null,new { @class = "btn btn-warning glyphicon glyphicon-plus-sign" }) </span>
我得到我的按钮,但创建新文本显示与glyphicon font-family。
将字形类放在span中不会改变任何东西
解决方法
您不应该将字形类添加到a-tag。
从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帮助程序不适用。相反,你可以使用像:
<a href="@Url.Action("Action","Controller")" class="btn btn-warning"> link text <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> </a>