Home  >  Article  >  Web Front-end  >  使用HTML.ActionLink实现一个图片链接_html/css_WEB-ITnose

使用HTML.ActionLink实现一个图片链接_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:23:181400browse

学习ASP.NET MVC 的Razor的语法,尝试把一段普能的图片链接使用HTML.ActionLink实现一个图片链接_html/css_WEB-ITnose改为HTML.ActionLink实现。

最原始的代码:

 <a href="index.html" class="logo">    <img src="Content/img/logo/logo4-corporation.png" alt="Logo"> </a>


Ok,你可以改为:

<a href="@Url.Action("Index", "Home")" class="logo">    <img  src='@Url.Content("~/Content/img/logo/logo4-corporation.png")' / alt="使用HTML.ActionLink实现一个图片链接_html/css_WEB-ITnose" ></a>


下面开始尝试改为Html.ActionLink:

@Html.ActionLink(" ", "Index", "Home", null, new{    style = "background: url('" +    Url.Content("~/Content/img/logo/logo4-corporation.png") +     "') no-repeat center right; display:block; height:84px; width:264px;"})



把样式代码,移至一个css样式文件或是代码块中:

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn