【问题标题】:How to Add ID to Html.ActionLink - Same as You Would In HTML / CSS如何将 ID 添加到 Html.ActionLink - 与 HTML / CSS 中的相同
【发布时间】:2017-10-13 16:51:34
【问题描述】:

我在 .cshtml 文件中有一行代码:

@Html.ActionLink("LION TECHNOLOGIES", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })

您可以看到文本 LION TECHNOLOGIES 已被赋予 navbar-brand 类。 Navbar-brand 是 bootstrap.css 中的一个类,我不想修改该文件,所以我想为 LION TECHNOLOGIES 分配一个 ID。如何为 LION TECHNOLOGIES 提供 ID navbar-text

我试过这个:

@Html.ActionLink("LION TECHNOLOGIES", "Index", "Home", new { area = "" }, new { @class = "navbar-brand"}, new {@id = "navbar-text"})

但它给了我一个错误:

(当鼠标悬停在红色下划线上方时)

Argument 6: cannot convert from <anonymous type: string class>' to 'System.Web.Mvc.Ajax.AjaxOptions'

我正在尝试链接到我的 style.css 文件,我正在尝试将标题中的 LION TECHNOLOGIES 更改为 font-family。 Style.css 将如下所示:

@font-face {
font-family: 'plantagenet_cherokeeregular';
src: url('fonts/plantagenet_cherokee-webfont.woff2') format('woff2'),
     url('fonts/plantagenet_cherokee-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;

}

#navbar-text {
font-family: 'plantagenet_cherokeeregular';
} 

谢谢。

【问题讨论】:

    标签: c# css asp.net-mvc twitter-bootstrap razor


    【解决方案1】:

    试试这个:

    @Html.ActionLink("LION TECHNOLOGIES", "Index", "Home", new { area = "" }, new { @class = "navbar-brand", @id = "navbar-text"})
    

    【讨论】:

    • 是的,做到了。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2012-05-19
    • 1970-01-01
    • 2013-09-09
    • 2015-07-27
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 2020-12-05
    相关资源
    最近更新 更多