附加图像ActionLink的MVC中4 [英] Attach image to ActionLink in MVC 4

查看:102
本文介绍了附加图像ActionLink的MVC中4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC 4应用程序中使用的ActionLink通过ID和assinging ActionLink的ID在CSS中的形象,但在地球上我做错了。不管用!这里是我的code

 < D​​IV CLASS =logo_container>
            @ Html.ActionLink(,索引,家,空,新的{ID =_Logo})
 < / DIV>

的CSS

  .logo_container {
宽度:339px;
高度:116像素;
}#_商标 {
背景图像:网址(../图像/ logo.png);
 宽度:339px;
高度:116像素;
背景颜色:绿色;
}


解决方案

这是从我的应用程序。工程确定:

  .logo {
背景:不重复URL(/Content/photo/png/sprite.png)0 0;
高度:15px的;
宽度:20像素;
溢出:隐藏;
浮动:左;
边界:无;
显示:内联;
}< A HREF =@ Url.Action(动作,控制器)级=标志>< / A>

I am using ActionLink with id in MVC 4 app and assinging actionLink id an image in css but on on earth I am doing wrong. is not working! here is my code

 <div class="logo_container">
            @Html.ActionLink(" ", "Index", "Home", null, new { id = "_Logo" })
 </div>

CSS

.logo_container {
width:339px;
height:116px; 
}

#_Logo {
background-image: url("../Images/logo.png");
 width:339px;
height:116px;
background-color:green;
}

解决方案

This is from my application. Works ok:

.logo{
background:no-repeat url(/Content/photo/png/sprite.png) 0 0;
height:15px;
width:20px;
overflow:hidden;
float:left;
border:none;
display:inline;
}

<a href="@Url.Action("Action", "Controller")" class="logo"></a>

这篇关于附加图像ActionLink的MVC中4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆