Home >Web Front-end >HTML Tutorial >行内元素外边距的问题_html/css_WEB-ITnose

行内元素外边距的问题_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-21 09:32:461203browse

<div style="margin:10px;background:blue">	<span style="margin-top:20px;background:red;">aaaaaaaa</span></div>


标签算是行内元素吧,但是为什么margin-top属性没发挥作用呢?它应该不会有重叠外边距的问题吧。


回复讨论(解决方案)

margin-top
margin-bottom 对 行内元素 无效,可以使用 padding

你在 标签上再加个display:block;
margin就有效了
如:

<div style="margin:10px;background:blue">    <span style=" display:block;margin-top:20px;background:red;">aaaaaaaa</span></div>

好的谢谢二位!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn