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

WBOY
Release: 2016-06-24 11:23:18
Original
1408 people have browsed it

学习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>
Copy after login


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>
Copy after login


下面开始尝试改为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;"})
Copy after login



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

 

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!