gpt4 book ai didi

css - 推荐的边距或填充是什么?

转载 作者:行者123 更新时间:2023-11-28 09:42:57 24 4
gpt4 key购买 nike

我已经制作了一些代码和 css,现在我正在学习理解它们..

如果我使用边距或填充有什么区别?建议在我的 <p> 上使用什么标签?

我现在正在使用边距,但边距用于元素的外部,如果填充用于内容和边框之间的空间,我为什么要使用它。

那么让我们开始吧:

<div id="MainContainer">
<section>
<article>
<h1>Title</h1>
<p> text text text text text </p>
</article>
</section>
</div>

我的 CSS 看起来像这样

#MainContainer {
width:980px;
margin:0 auto;

background-color:#FFF;

}

article {
text-align:left;
color:#000000;
padding-left: 205px;
padding-bottom: 25px;
}

section {

margin-left: 10px;
margin-right: 10px;
height:350px;
}
p {
margin: 10px 0px 15px 0px;
}

最佳答案

一个重要的区别(除了 margin 表示外部,padding 表示内部):相邻元素的边距重叠,而 paddings 不重叠.举个例子:

<p>Lorem ipsum</p>
<p>Dolor sic amet</p>

如果您使用 margin :

p { margin: 10px 0; }

这两段之间的间距为10px

但是如果你去:

p { padding: 10px 0; }

内容将被20px分隔。

关于css - 推荐的边距或填充是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25348213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com