简体   繁体   English

div周围有多余的空间

[英]extra space around div

I have a problem here i am getting space around this text i was not able to get rid off. 我在这里遇到问题,我在此文字周围留出空间,无法摆脱。 i cannot apply globally padding:0 or margin:0 to the all divs. 我无法对所有div全局使用padding:0或margin:0。 My div is part of the page i want to remove extra space around my div alone i cannot apply padding:0 or margin:0 to body also. 我的div是页面的一部分,我想单独删除div周围的多余空间,我也无法将padding:0或margin:0应用于body。

<html>
<body>
<div class="topcont" id="topcont" style="display: block;padding:0px;margin:0px">
<div  id="dragcont" style="display: block;padding:0px;margin:0px">
    <div style="padding:0px;margin:0px; text-align: center; font-size: 18px; font-weight: bold; font-family: Helvetica Neue;">
        Drop up to 5 photos here
    </div>
    <div style="padding:0px;margin:0px; font-size: 18px; font-family: Helvetica Neue; border: 0px none; height: 18px; text-align: center;">
        Or
    </div>
</div>
<div style="padding:0px;margin:0px;color:#333; text-align:center; font-size:14px;font-family:Helvetica Neue">
   to add them as attachments
</div>
</div>
</body>
</html>

I dont know why i am getting space above the given texts. 我不知道为什么我在给定的文本上方留出空间。

You can easily set margins to 0 using the following on any element. 您可以在任何元素上使用以下内容轻松将边距设置为0。

#myDiv{
margin:0px;
}

Note the 0px; 注意0px; and not 0; 而不是0;

For rendering/optimization purposes its good to include the unit of measurement (eg px,em,etc) 出于渲染/优化的目的,最好包含度量单位(例如px,em等)

您需要将与其边界的元素的边距设置为0,这取决于布局的其余部分(可能仅针对相关方向)。

http://jsfiddle.net/sCj6y/1/可以使用,但您不应在HTML文件中设置样式。

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

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