有没有办法使用 BMVC(又名 TwitterBootstrapMVC5)来做到这一点?
示例 Razor 页面如下:
@{
var alt = "microsoft homepage";
var url = "http://www.microsoft.com/";
var logo = "~/Content/Images/microsoft_logo.png";
}
<!-- The old school way works just fine; also not using any variables -->
<a href="http://www.microsoft.com/">
<img alt="microsoft homepage" src="~/Content/Images/microsoft_logo.png" />
</a>
<!-- This does not work using BMVC (the link works but fails at rendering the logo and has no alternate text) -->
@Html.Bootstrap().Link(@logo, @url)
换句话说,是否有一种“简短而有趣”的方法来使用 BMVC 创建链接(带有图像)?
最佳答案
https://www.twitterbootstrapmvc.com/Documentation#buttons-link 嗯?
我意识到这只是一个链接,但文档应该足够了
基本用法
@Html.Bootstrap().Link("awesome website", "http://www.website.net")
HTML 输出
<a href="http://www.website.net">awesome website</a>
我想我错过了什么。你想要那里,不是吗?
也许
@Html.Bootstrap().Link("<img src=\"@logo\"/>", "http://www.website.net")
?
关于c# - 如何创建带有图像的 BMVC (TwitterBootstrapMVC) 链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21029736/