网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站设计 > CSS, DIV, HTML
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 117.95.90.6
Old 2014-12-31, 11:35 AM
Hartland Hartland is offline
初级会员
 
Join Date: 2006-09-23
Posts: 1
Hartland 现在声名狼藉
Default 解决footer层不显示

Code:
<html>
	<head>
            <meta http-equiv="content-type" content="text/html; charset=utf8" /> 
		
		<title>study css and div</title>
		<style type="text/css">
			#container{
				width:1002px;
				background-color: grey;
			}

			#header{
				width:1002px;
				height:120px;
				background-color:red;
			}
			
			#main{
                                                        width:1002px;
                                                        height: 700px
				background-color:green;
			}

			#lside{
				float:left;
				width:700px;
				height:700px;
				background-color:purple;
			}
			#rside{
				float:left;
				width:302px;
				height:700px;
				background-color:pink;
			}
			#footer{
		   		width:1002px;
				height:120px;
				background-color:yellow;
			}
		</style>
	</head>
	<body>
	    <div id="container"></div>
		<div id="header"></div>
		<div id="main">
			<div id="lside"></div>
			<div id="rside"></div>
		</div>
 
		<div id="footer"></div>
	</body>
</html>
上边的代码可以正常显示footer部分的, 可有个问题, 如main部分的内部高度有变化呢?一般就要删除main中的高度:height: 700px;这行, 变成:
Code:
<html>
	<head>
            <meta http-equiv="content-type" content="text/html; charset=utf8" /> 
		
		<title>study css and div</title>
		<style type="text/css">
			#container{
				width:1002px;
				background-color: grey;
			}

			#header{
				width:1002px;
				height:120px;
				background-color:red;
			}
			
			#main{
                                                        width:1002px;
				background-color:green;
			}

			#lside{
				float:left;
				width:700px;
				height:700px;
				background-color:purple;
			}
			#rside{
				float:left;
				width:302px;
				height:700px;
				background-color:pink;
			}
			#footer{
		   		width:1002px;
				height:120px;
				background-color:yellow;
			}
		</style>
	</head>
	<body>
	    <div id="container"></div>
		<div id="header"></div>
		<div id="main">
			<div id="lside"></div>
			<div id="rside"></div>
		</div>
 
		<div id="footer"></div>
	</body>
</html>
这样就会有另一个问题, footer部分不显示了, 解决方法:在footer的css中加一行clear:both;让footer层与上边的左/右两边层不重叠:

Code:
<html>
	<head>
            <meta http-equiv="content-type" content="text/html; charset=utf8" /> 
		
		<title>study css and div</title>
		<style type="text/css">
			#container{
				width:1002px;
				background-color: grey;
			}

			#header{
				width:1002px;
				height:120px;
				background-color:red;
			}
			
			#main{
                                                        width:1002px;
				background-color:green;
			}

			#lside{
				float:left;
				width:700px;
				height:700px;
				background-color:purple;
			}
			#rside{
				float:left;
				width:302px;
				height:700px;
				background-color:pink;
			}
			#footer{
		   		width:1002px;
				height:120px;
				background-color:yellow;
				clear:both;
			}
		</style>
	</head>
	<body>
	    <div id="container"></div>
		<div id="header"></div>
		<div id="main">
			<div id="lside"></div>
			<div id="rside"></div>
		</div>
 
		<div id="footer"></div>
	</body>
</html>
或者将clear:both;改成float:left;

Last edited by Hartland : 2014-12-31 at 12:39 PM
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:05 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.