`
zzc1684
  • 浏览: 1191124 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

行内元素和margin叠加问题

阅读更多

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>

	<span style="background-color:#FF0000;">行内元素正常状态</span>
	
	<span style="background-color:#FF99FF; width:1000px; height:1000px;">行内元素设置宽高没效,width:100px; height:1000px;</span>
	
	<span style="background-color:#99FFCC; margin-left:100px; margin-right:100px; margin-top:200px; margin-bottom:200px;">行内元素设置margin-top,margin-bottom无效, margin-left, margin-right有效</span>
	
	<br />
	
	<span style="background-color:#CCCC00; line-height:100px;">行内元素设置line-height:100px;有效</span>
	
	<span style="background-color:#99FFCC; display:block;">行内元素变成块状,display:block;</span>
	
	<span style=" background-color:#FF00FF; display:block; height:200px; width:200px;">行内元素变成块状,display:block,设置宽高:width:200px; height:200px;</span>
	
	<span style="background-color:#33FF66; display:inline-block; width:600px; height:200px; line-height:100px; text-align:center; margin:40px;">设置为内联块状inline-block,行内元素既可以设置宽度和高度,也可以设置line-height,text-align,margin</span>
		<span style="background-color:#33FF66; display:inline-block; width:600px; height:200px; line-height:100px; text-align:center; margin:40px;">设置为内联块状inline-block,行内元素既可以设置宽度和高度,也可以设置line-height,text-align,margin</span>
		
		
		
		<div>margin重叠问题,上下重叠</div>
		<div style="width:100px; height:100px; background-color:#003366; margin-bottom:40px; overflow:hidden;">margin-bottom和margin-top重叠</div>
		<div style="width:100px; height:100px; background-color:#009900; margin-top:40px;">margin-bottom和margin-top重叠</div>
		
		
		<div>margin重叠问题,父子元素重叠</div>
		<div style="width:1000px; height:100px; background-color:#CCCC00; margin-top:40px;">
			<div style="width:500px; height:50px; background-color:#00CC00; margin-top:40px;">
				子元素的margin-top:40px和父元素的maragin-top:40px重叠
			</div>
		</div>
		<div style="width:1000px; height:100px; background-color:#CCCC00; margin-top:40px; overflow:hidden;">
			<div style="width:500px; height:50px; background-color:#00CC00; margin-top:40px;">
				解决方式,父元素加overflow:hidden;
			</div>
		</div>
</body>
</html>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics