阅读背景:

DIV+CSS关于浮动跑到上面的原因

来源:互联网 

今天,遇到了一个问题就是div地底部莫名其妙的跑到上面去了。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
	body{ text-align:center;}
	.top{ width:960px; height:100px; background-color:#003300; margin:0 auto;}
	.main{ margin:0 auto; width:960px;}
	.a{ float:left; margin-left:10px;}
	#left{ height:100px;}
	#center{ height:200px;}
	#right{ height:50px;}
	.bottom{ width:960px; height:140px; background-color:#003399; margin:0 auto; }
</style>
</head>

<body>
	<div class="top"><h1 style="color:#CCCCCC;">TOP</h1></div>
    <div class="main">
    	<div class="a" id="left">
        	<div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">LEFT</h1></div> 
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">LEFT</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">LEFT</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">LEFT</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">LEFT</h1></div>        
        </div>
        <div class="a" id="center">
        	<div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">CENTER</h1></div> 
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">CENTER</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">CENTER</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">CENTER</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">CENTER</h1></div>     
        </div>
        <div class="a" id="right">
        	<div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">RIGHT</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">RIGHT</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">RIGHT</h1></div>
            <div style="width:100px; height:100px; background-color:#660000; margin-bottom:10px;"><h1 style="color:#FFFFFF">RIGHT</h1></div>  
        </div>
        <div style="clear:both;"><h1>Clear Float DIV</h1><br /></div>
    </div>
    <div class="bottom" style="background-color:#FF0000; text-align:center;"><h1 style="color:#FFFFFF">BOTTOM</h1></div>
</body>
</html>
<!DOCTYPE h



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: