ASP.NET ActionLink的与glyphicon和文本不同的字体 [英] ASP.NET Actionlink with glyphicon and text with different font

查看:128
本文介绍了ASP.NET ActionLink的与glyphicon和文本不同的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要present与 @ Html.ActionLink 按钮,但我需要在文字我的应用程序的字体。

I want to present a button with @Html.ActionLink but i need to have my application font in the text.

有了这个code:

<span>
    @Html.ActionLink("  Create New", "Create", null, new { @class = "btn btn-warning glyphicon glyphicon-plus-sign" })
</span>

我得到我的按钮,但在新建文本出现与glyphicon FONT-FAMILY。

I get my button but the Create New text appears with the glyphicon font-family.

把glyphicon类的跨度不会改变任何东西。

Putting the glyphicon classes in the span doesn't change anything

推荐答案

您应该不glyphicon类添加到一个标签。

You should not add the glyphicon class to the a-tag.

从引导网站:

不要与其它成分混合
  图标类不能与其它组分直接混合。他们不应该在相同的元素其他类一起使用。相反,添加一个嵌套和图标类应用到

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 and apply the icon classes to the .

仅适用于空元素使用
  图标类应该只包含没有文本内容,也没有子元素的元素使用。

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:&LT; A HREF =#类=BTN BTN-警告&GT;测试&LT;跨度类= glyphicon glyphicon加符号&GT;&LT; / SPAN&GT;&LT; / A&GT;

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>

这使得 Html.ActionLink 帮手不合适。相反,你可以使用这样的:

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>

这篇关于ASP.NET ActionLink的与glyphicon和文本不同的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆