posts - 20,  comments - 2,  trackbacks - 0

作者: tianshi0253  链接:http://tianshi0253.javaeye.com/blog/205269  发表时间: 2008年06月18日

声明:本文系JavaEye网站发布的原创博客文章,未经作者书面许可,严禁任何网站转载本文,否则必将追究法律责任!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>height auto</title>
		<style type="text/css">
		html,body{text-align:center; margin:0px; padding:0px;}
			#box {
			overflow:auto; border:solid 1px red; float:left; margin-left:auto; margin-right:auto; width:80%; 
			}
			
			.subbox{
				display:inline;
				display:block;
				
				float:left;
				width:100px;
				height:100px;
				margin:50px;
				border:solid 1px red;
				
			}
			
			.clear{
				clear:both;
			}
			</style>
		</head>
		<body>
			<div id="box">
				<div class="subbox"></div>
                <div class="subbox"></div>
				<div class="subbox"></div>
                <div class="subbox"></div>
			    <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
				<div class="subbox"></div>
                <div class="subbox"></div>
			    <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
				<div class="subbox"></div>
                <div class="subbox"></div>
			    <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
				<div class="subbox"></div>
                <div class="subbox"></div>
			    <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
				<div class="subbox"></div>
                <div class="subbox"></div>
			    <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
                <div class="subbox"></div>
				<div class="subbox"></div>
                <div class="subbox"></div>
			    <div class="subbox"></div>
                <div class="subbox"></div>
                
                
                
				<div class="clear"></div>
			</div>
		</body>
</html>

 

要让某个层高度自适应,要把它的属性float设置为left或right值;

在其中建一个层,并设置属性clear:both.


本文的讨论也很精彩,浏览讨论>>


JavaEye推荐




文章来源:http://tianshi0253.javaeye.com/blog/205269
posted on 2008-06-18 17:40 姚文超 阅读(91) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: