Heim  >  Artikel  >  Web-Frontend  >  使用HTML.ActionLink实现一个图片链接_html/css_WEB-ITnose

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

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

学习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样式文件或是代码块中:

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn