Search code examples
c#htmlcssasp.net-mvcview

ASP.NET MVC view add stylesheet class or change bootstrap


When I'm adding css classes or changing bootstrap classes on view html in ASP.NET MVC, nothing happens.

CSS stylesheet

.icon {
    margin-top: 8px;
    border: 1px solid white;
    border-radius: 100%;
}

.titleLibrary{
    color: gray;
}

View html

<a href="@Url.Action("Index","Home")">
   <img src="@Url.Content("~/Icons/bookIcon.jpg")" width="50" class="icon" />
</a>
   @Html.ActionLink("Library", "Index", "Home", new { area = "" }, new { @class = "titleLibrary" })

screenshot

but when I use style in html everything is fine

<a href="@Url.Action("Index","Home")">
   <img src="@Url.Content("~/Icons/bookIcon.jpg")" width="50" style=" border: 1px solid white; border-radius: 100%;" />
</a>

Solution

  • If you are not clearing the cache, then this may be a reason for not reflecting the updated CSS style in your Index or any other page. So try to clear the cache and then try to update the style. For clearing cache use Ctrl+F5. This will helps to clear the cache. The another solution, if you are keeping the style.css file separately, then please give the reference link at the top the Index page, then refresh and rebuild the page and try again.

    <head>  
     <link href="~/Content/background.css" rel="stylesheet" />
    </head>