Home > Web Front-end > HTML Tutorial > CSS浮动相关问题_html/css_WEB-ITnose

CSS浮动相关问题_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:32:24
Original
1219 people have browsed it





CSS代码:div{width:100px;height:100px;background:#000;border:2px solid #f00;float:left;}
.clear{height:50px;}
HTML代码:

cc





如果把P元素改成div元素为什么会产生完全不同的结果(当然要把这个有类的div元素float:none)








回复讨论(解决方案)

p有默认的margin、padding什么的

如果你将中间p改成的div设置一个更大的宽度的话就应该知道没什么区别了

.clear{width:100px;height:50px;}
也行

*{margin:0;padding:0}

建议先用这个把所有元素重置。然后的话效果就应该是一样的了。因为DIV和P都是块状元素。

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