Home > Blockchain >  ASP.NET MVC view add stylesheet class or change bootstrap
ASP.NET MVC view add stylesheet class or change bootstrap

Time:11-30

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>

CodePudding user response:

Hey Ivan have you made sure to render your styles on your view you are using? For instance if you are using a layout page you usually would render your style bundle or sheet at the head of the layout page.

I'll give you an example

<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>Project System</title>
    @Styles.Render("~/content/site-bundle")
    @RenderSection("styles", false)
</head>

Here you can see me render my style bundle. In this case you can instead render your stylesheet you have.

CodePudding user response:

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