是什么让我的img移动到一个不相关的div内部?

时间:2017-01-04 21:14:35

标签: c# asp.net-mvc twitter-bootstrap

我正在使用C#和bootstrap在ASP.NET中编写一个网页。我正在尝试更改_Layout。这就是我所拥有的:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - B5 Tours</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    <div id="headerbar">RF Center of Excellence</div>
    <div class="container body-content">
        @RenderBody()
        <div style="clear:both;" />
    </div>
    <img src="~/Content/FooterPicture2.png" style="" />

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

注意图片,在div之外使用类containerbody-content。但是,当我运行网站并点击f12浏览DOM,然后点击图片查找它时,我会看到container body-content div内的图像。

<div class="container body-content">  
    <div class="col-sm-1 customer-block">
    </div>
    <div class="col-sm-1 customer-block">
    </div>
    <div class="col-sm-1 customer-block">
    </div>
    <div style="clear: both;">
    </div>
    <img src="/Content/FooterPicture2.png">

    <script src="/Scripts/jquery-1.10.2.js"></script>

    <script src="/Scripts/bootstrap.js"></script>
    <script src="/Scripts/respond.js"></script>



    <!-- Visual Studio Browser Link -->
    <script id="__browserLink_initializationData" type="application/json">
        {"appName":"Internet Explorer","requestId":"b2e6b58079644495a5751a037fd16748"}
    </script>
    <script src="http://localhost:63389/a1a3529e4ef74c2e9f1fb2137876c0af/browserLink" type="text/javascript" async="async"></script>
    <!-- End Browser Link -->
</div>

那是什么给出的?是bootstrap.js移动吗?它如何决定搬家?我该如何阻止这种情况发生?

1 个答案:

答案 0 :(得分:3)

这是一种无效的语法

<div style="clear:both;" />

根据specification <div>总是以</div>结尾,所以正确的是

<div style="clear: both;"></div>