【问题标题】:Visual Studio automatically closing DIV surrounding LegendVisual Studio 自动关闭 DIV 周围的 Legend
【发布时间】:2012-11-16 19:26:15
【问题描述】:

所以我在整个项目中都有一些代码,

 <fieldset>
        <div  class="legendContainerInactive">
            <legend>Legend Stuff
            </legend>
        </div>
 ....
 </fieldset>

这让我的传奇故事的顶部变得漂亮而饱满 - 基本上是一个颜色条。但是,Visual Studio 已决定不能将 Legends 包含在 div 中。这可能是某个地方的标准,但天哪,我的代码是这样工作的,在所有浏览器上看起来都很棒。

每次我保存 Visual Studio 时都会添加一个关闭 div,所以它看起来像这样

 <fieldset>
        <div  class="legendContainerInactive">
        </div>
            <legend>Legend Stuff
            </legend>
        </div>
 ....
 </fieldset>

所以我的页面不断中断,因为 VS 决定的额外 div 非常重要。我已禁用 VS 关闭格式化程序中的 div,并阻止它关闭标签。它一直在这样做。啊!如何让它停止?

【问题讨论】:

    标签: visual-studio-2010 html legend autoformatting


    【解决方案1】:

    这是因为&lt;legend&gt; 不应在&lt;div&gt; 标记下&lt;legend&gt; 只能在&lt;fieldset&gt; 下使用,&lt;fieldset&gt; 本身是&lt;form&gt; 标记的子级。

    Correct Syntax-Structure to use these will be somewhat like this:

    <form>
        <fieldset>
            <legend> … </legend>
        </fieldset>
    </form>
    

    所以一开始你不应该以这种方式使用它,VS 会继续纠正它,但如果你仍然想使用比:

    • 您可以在 Options > Text Editor > HTML > Formatting 中禁用此自动标记关闭功能并取消选中 Auto insert close tag 的复选框。

    但是我仍然建议遵守标准约定和规则,你永远不知道下一次浏览器更新会给你带来什么..

    见:

    HTML legend Tag

    DTD (Document Type Definition)

    谢谢。

    【讨论】:

    • 嗨!谢谢,但我已经禁用了自动标签关闭,它仍在这样做。似乎视觉工作室的不同部分正在参与其中。
    • 您是否安装了诸如Resharper 之类的其他插件?
    猜你喜欢
    • 2011-06-27
    • 2014-05-28
    • 1970-01-01
    • 2022-01-15
    • 2010-09-07
    • 2010-10-18
    • 1970-01-01
    • 2014-09-06
    相关资源
    最近更新 更多