加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ASP.NET Actionlink与glyphicon和文本与不同的字

发布时间:2020-12-15 19:38:13 所属栏目:asp.Net 来源:网络整理
导读:我想提出一个按钮与@ Html.ActionLink,但我需要有我的应用程序字体在文本中。 有了这个代码: span @Html.ActionLink(" Create New","Create",null,new { @class = "btn btn-warning glyphicon glyphicon-plus-sign" })/span 我得到我的按钮,但创建新文本
我想提出一个按钮与@ 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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读