locked
Site.css My-MenuBar is not noticed by div tag in _Layout.cshtml RRS feed

  • Question

  • User916754777 posted

    In my MVC 4.5.2 C#, .NET Framework 4.5.2 application the Site.css My-MenuBar is not noticed by div tag in _Layout.cshtml

    Did I do something wrong or was the layout page designed not to access the Site.css file?

    Site.css

    div#My-MenuBar {
    border: 5px solid black;
    background-color: red;
    padding-top: 50px;
    padding-right: 30px;
    padding-bottom: 50px;
    padding-left: 80px;

    }

    _Layout.cshtml

    <div id="My-MenuBar"> Welcome </div>

    Wednesday, October 26, 2016 9:19 PM

Answers

  • User916754777 posted

    I forgot to hard refresh the browser. My code was good, I was looking at old results. Thank you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 27, 2016 6:50 PM

All replies

  • User-1838255255 posted

    Hi Cadel,

    According to your description and Code, I make a sample in MVC , I add _Layout.cshtml in _Viewstart.cshtml ,it run perfect . You can reference it:

    Sample Code:

    _Layout.cshtml:
    
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>@ViewBag.Title - My ASP.NET Application</title>
        <link href="~/Site.css" rel="stylesheet" />
    
    </head>
    <body>
        <div>
            <header>
                <div id="My-MenuBar">Welcome </div>
            </header>
            <div id="body">
                @RenderBody()
            </div>
        </div>
    </body>
    </html>
    
    _Viewstart.cshtml:
    @{
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    Site.css:
    div#My-MenuBar {
     border: 5px solid black;
     background-color: red;
     padding-top: 50px;
     padding-right: 30px;
     padding-bottom: 50px;
     padding-left: 80px;
    }
    
    

    Here is file position Screen shoot:

    Result:

    Best Regards,

    Eric Du

    Thursday, October 27, 2016 4:06 AM
  • User916754777 posted

    I forgot to hard refresh the browser. My code was good, I was looking at old results. Thank you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 27, 2016 6:50 PM