简体   繁体   中英

ASP.NET MVC _Layout.cs is removing my divs?

        <div class="left-sidebar">
            <ul>
                <li>@Html.ActionLink("Guild", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })</li>
                @*<li>@Html.ActionLink("A", "A", "Home")</li>*@
                <li>@Html.ActionLink("B", "B", "Home")</li>
                <li>@Html.ActionLink("C", "C", "Home")</li>
                <li>@Html.ActionLink("D", "D", "Home")</li>
            </ul>
        </div>

        <div class="main-content">
            @RenderBody()
            <hr />
        </div>

        <div class="clear" /> // This goes missing on output?!

I have a left-sidebar and an main content, I'm using css to make the two divs float side by side. I need the "Clear" so the footer doesn't hover over the divs.

However, when I run the website the preview my Clear divs are gone in the _Layout.cs BUT if I have them in my @RenderBody they appear as they should.

div is not allowed to omit the closing element so the form <div /> is invalid. Put it as <div class="clear"></div> instead and check.

From documentation about div element :

Tag omission: None, both the starting and ending tag are mandatory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM