【问题标题】:HTML - Making proper use of DIV tagHTML - 正确使用 DIV 标签
【发布时间】:2016-12-15 18:32:39
【问题描述】:

以下是我的代码示例 -

    <html>
    <body bgcolor="red">
     <div class='log' style="background-color:white;width:auto; margin:0; padding:15px 20px">
     <marquee scrollamount="6" scrolldelay="100"><font size='4' color='black'>Test</marquee>
    <hr>
</div>
    </body>
    </html>

当我运行它时,我可以看到额外的 div 空间,有没有什么办法可以去除多余的 div 空间? 谢谢。

【问题讨论】:

  • 你在哪里关闭&lt;/div&gt; 标签?此外,&lt;marquee&gt; 标记已过时。认为它可能有效,但强烈建议不要在较新的应用程序中使用它。
  • 尝试将margin: 0; padding: 0 添加到body 元素?
  • 1.你从来没有关闭你的 div 标签。它是用来包围选框标签的吗? 2.你是什么意思“额外的div空间”?你已经为你的 div 添加了 padding,这就是你说的空间吗?
  • 仅供参考,您使用的是过时的功能,包括bgcolor&lt;font&gt; 和..&lt;marquee&gt;!?
  • 对不起,伙计们.. 不小心粘贴了我程序中的旧代码。需要更新一下

标签: javascript jquery html css random


【解决方案1】:

删除填充。

<html>
    <body bgcolor="red">
        <div class="log" style="background-color:white;width:auto; margin:0;" >
            <marquee scrollamount="6" scrolldelay="100"><font size='4' color='black'>Test</marquee>
            <hr>
        </div>
    </body>
</html>

【讨论】:

    【解决方案2】:

    删除顶部和底部填充以删除您所说的这个“额外”空间。但是,如果你指的是身体,不,没有办法缩短它的高度。

    <div class='log' style="background-color:white;width:auto; margin:0; padding:15px 0px">
    

    另外,你忘了关闭你的 div 标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多