简体   繁体   English

注释导致代码显示不正确(CSS / Bootstrap)

[英]A Comment is causing code to display incorrectly (CSS/Bootstrap)

This is one of the strangest things I have encountered. 这是我遇到的最奇怪的事情之一。 A COMMENT (or lack thereof) is causing the output to change. COMMENT (或缺少COMMENT )导致输出更改。 See this below, notice the <!-- and --> in the middle. 请参阅下面的内容,注意中间的<!---->

    <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
        <div class="row">
            <div class="col-xs-6 col-md-8 col-lg-8 vertical-center">
                <h2>
                    TEST
                    <small>
                        <span>Test</span>
                    </small>
                </h2>
            </div><!--
        --><div class="col-xs-6 col-md-4 col-lg-4 vertical-center">
                <h2 class="text-right skip-pause-buttons">
                    <span class="glyphicon glyphicon-step-backward"></span>
                    <span class="glyphicon glyphicon-pause"></span>
                    <span class="glyphicon glyphicon-step-forward"></span>
                </h2>
            </div>
        </div>
    </nav>

If I have it there, it displays okay. 如果我在那里,它会显示正常。 If I remove it, the code stops displaying correctly. 如果删除它,代码将停止正确显示。 See this image: 看到这张图片:

在此处输入图片说明

The top case is WITHOUT the comment (for some reason it displays on two lines). 大写字母没有注释(出于某种原因,它显示在两行中)。 The bottom case is WITH the comment (displays correctly). 小写字母是WITH注释(正确显示)。

What on earth is going on? 到底是怎么回事?


EDIT: I just noticed if the is on the same line as the (even without the comment) it displays correctly. 编辑:我只是注意到,如果与(即使没有评论)在同一行,则显示正确。 But as soon as it's on a different line, it stops displaying correctly. 但是,只要它在另一行上,它就会停止正确显示。

The comments are used to remove any whitespace between the two elements (you can achieve the same results with float left) 注释用于删除两个元素之间的任何空格(您可以通过向左浮动获得相同的结果)

Usually is better to use grid classes only for grid purpose. 通常最好仅将网格类用于网格目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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