Search code examples
cssasp.net-mvcrazoractionlink

Attach image to ActionLink in MVC 4


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;
}

Solution

  • 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>