码迷,mamicode.com
首页 > Web开发 > 详细

css实现缩进无限嵌套

时间:2015-03-10 15:18:00      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

使用css实现缩进带背景无限嵌套,支持Ie6,代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
*{margin:0;padding:0;}
li{list-style:none;}
.box{width:300px;height:400px;border:2px solid #ccc;margin:10px;position:relative;}
.box li{padding-left:15px;line-height:20px;}
.box a{display:block;}
.box .bg{position:absolute;z-index:-1;left:0;width:300px;height:20px;background:#ccc;opacity:0;filter:alpha(opacity=0);}
.box a:hover .bg{opacity:1;filter:alpha(opacity=100);}
	</style>
</head>
<body>
	<div class="box">
		<ul>
			<li>
				<a href="#"><span class="bg"></span>12</a>
				<ul>
					<li>
						<a href="#"><span class="bg"></span>12</a>
						<ul>
							<li>
								<a href="#"><span class="bg"></span>12</a>
								<ul>
									<li><a href="#"><span class="bg"></span>12</a></li>
									<li><a href="#"><span class="bg"></span>12</a></li>
								</ul>
							</li>
							<li><a href="#"><span class="bg"></span>12</a></li>
						</ul>
					</li>
				</ul>
			</li>
		</ul>
	</div>
</body>
</html>

  

css实现缩进无限嵌套

标签:

原文地址:http://www.cnblogs.com/ayseeing/p/4325954.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!