gpt4 book ai didi

css - 想要在 Html.ActionLink 中使用带有文本的图像

转载 作者:行者123 更新时间:2023-11-28 10:56:51 26 4
gpt4 key购买 nike

我正在使用以下内容:

<img src="../../Content/Images/lock_16.gif" />
@Html.ActionLink("Register",
"Register",
"Users",
null,
new { title = "Register your ID", rel = "nofollow"
})

我希望锁图像出现在 <a> </a> 中所以它是可点击的,而不是在它之前。我已经使用(并在悬停时更改颜色)背景图像,因此我无法使用 background-image 属性来显示图像。

谁能想出一种方法来设置图像,使其显示在文本之前并且仍然可以点击。希望我能找到一种仍然允许我使用 MVC Html.ActionLink 的方法。

最佳答案

ASP.NET MVC 中的 Html 帮助程序在简化代码编写时应该使用,但并非总是如此。在您的情况下,纯 html 会更好

<a href="@Url.Action("Register", "Users")" title="Register Your ID", rel="nofollow">
Register <img src="@Url.Content("~/Content/Images/lock_16.gif")" />
</a>

请注意,链接地址仍然是动态生成的,使用 UrlHelper.Action 方法。这样,您就不会失去对路由配置的链接依赖性。另外,正如 Nicholas 提到的,图像源应该通过 Url.Content 帮助程序生成。

关于css - 想要在 Html.ActionLink 中使用带有文本的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6937775/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com