js实现只显示一个骰子页面,其余的不显示(HTML使用栅格布局实现六种筛子的样式)

   日期:2020-06-05     浏览:111    评论:0    
核心提示:页面开始的时候就运行,效果图:.big{width:100px;height:100px;background:skyblue;display:flex;

页面开始的时候就运行,效果图:

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.big {
				width: 100px;
				height: 100px;
				background: skyblue;
				display: flex;
				margin-top: 20px;
			} 
			.small {
				width: 10px;
				height: 10px;
				background: purple;
				border-radius: 5px;
			}
			
			.one {
				display: flex;
				justify-content: center;
				
				align-items: center;
			}
			
			.two {
				display: flex;
				justify-content: space-around;
				align-items: center;
			}
			
			.two2 {
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				align-items: center;
			}
			
			.three {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;
			}
			
			.four {
				display: flex;
				justify-content: space-around;
			}
			
			.four1 {
				display: flex;
				justify-content: space-around;
				align-items: center;
			}
			
			.four2 {
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				align-items: center;
			}
			
			.five {
				display: flex;
				justify-content: space-around;
			}
			
			.five1 {
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				align-items: center;
			}
			
			.five2 {
				display: flex;
				flex-direction: row;
				align-self: center;
			}
			
			.six {
				display: flex;
				justify-content: space-around;
			}
			
			.six1 {
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				align-items: center;
			}
		</style>
	</head>

	<body>
		<div class="big one">
			<div class="small"></div>
		</div>
		<div class="big two">
			<div class="small"></div>
			<div class="small"></div>
		</div>
		<div class="big two2">
			<div class="small"></div>
			<div class="small"></div>
		</div>
		<div class="big three">
			<div class="small" style="align-self: flex-start;"></div>
			<div class="small" style="align-self: center;"></div>
			<div class="small" style="align-self: flex-end;"></div>
		</div>
		<div class="big three">
			<div class="small" style="align-self: flex-end;"></div>
			<div class="small" style="align-self: center;"></div>
			<div class="small" style="align-self: flex-start;"></div>
		</div>
		<div class="big four">
			<div class="four2">

				<div class="small"></div>
				<div class="small"></div>
			</div>
			<div class="four2">

				<div class="small"></div>
				<div class="small"></div>
			</div>
		</div>
		<div class="big five">
			<div class="five1">

				<div class="small"></div>
				<div class="small"></div>
			</div>
			<div class="five2">

				<div class="small"></div>
			</div>
			<div class="five1">

				<div class="small"></div>
				<div class="small"></div>
			</div>
		</div>

		<div class="big six">
			<div class="six1">
				<div class="small"></div>
				<div class="small"></div>
				<div class="small"></div>
			</div>
			<div class="six1">
				<div class="small"></div>
				<div class="small"></div>
				<div class="small"></div>
			</div>
		</div>
		<div class="big six">
			<div class="six1">
				<div class="small"></div> 
				<div class="small"></div>
			</div>
			<div class="six1">
				<div class="small"></div>
				<div class="small"></div> 
			</div>
			<div class="six1">
				<div class="small"></div>
				<div class="small"></div> 
			</div>
		</div>
		<input type="button" value="开始" onclick="start()" />
		<input type="button" value="结束" onclick="stop()" />
	</body>
	<script>
		var interval;
			var i = 0;
		window.onload=start();
		function start () {
			var num = document.getElementsByClassName("big"); 
		  interval=	setInterval(function function_name () {
				for(var  j = 0;j<num.length;j++){
					if(j==i){
						num[j].style.display="flex";
					}
					else{
						num[j].style.display="none";	
					} 
				}
				i++;
				if(i==num.length){
					i=0;
				}
			},1000)
				
			 
		}
		function stop () {
			clearInterval(interval);
		}
	</script>

</html>
 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
更多>相关资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服