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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-21 09:32:46
Original
1208 people have browsed it

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


标签算是行内元素吧,但是为什么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>
Copy after login

好的谢谢二位!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template