前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >sass中循环结构

sass中循环结构

作者头像
贵哥的编程之路
发布2020-10-28 10:36:57
4940
发布2020-10-28 10:36:57
举报
文章被收录于专栏:用户7873631的专栏
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		/*ul
		{
			li
			{
				width: 100%;
				height: 50px;
				border: 1px solid red;
				font-size: 20px;
				background: red;
				/*这下面是less的写法:
			&:nth-child(5)
			{
				background:yellow;
			}
			&:nth-child(6)
			{
				background:red;
			}
			&:nth-child(7)
			{
				background:blue;
			}
			&:nth-child(8)
			{
				background:black;
			}
			}
			}
			*/
		/*less编译后的css文件*/
		/*
		

ul li {
  width: 100%;
  height: 50px;
  border: 1px solid red;
  font-size: 20px;
  background: red;
}
ul li:nth-child(5) {
  background: yellow;
}
ul li:nth-child(6) {
  background: red;
}
ul li:nth-child(7) {
  background: blue;
}
ul li:nth-child(8) {
  background: black;
}

		 */
		
/*ul{
  li{
    width: 100%;
    height: 50px;
    border: 1px solid #000;
    font-size: 20px;
    color: #fff;
    background: red;
    @for $i from 5 through 8
    {
    	$i:5;
    	&:nth-child(#{$i})
    	{
    		background: red;
    	}
    	$i:$i+1;
    }
}}*/
/*编译后的css文件*/
/*

ul li {
  width: 100%;
  height: 50px;
  border: 1px solid #000;
  font-size: 20px;
  color: #fff;
  background: red;
}
ul li:nth-child(5) {
  background: red;
}
ul li:nth-child(5) {
  background: red;
}
ul li:nth-child(5) {
  background: red;
}
ul li:nth-child(5) {
  background: red;
}

 */
/*ul{
  li{
    width: 100%;
    height: 50px;
    border: 1px solid #000;
    font-size: 20px;
    color: #fff;
    background: red;
    @for $i from 5 to 8
    {
    	$i:5;
    	&:nth-child(#{$i})
    	{
    		background: red;
    	}
    	$i:$i+1;
    }
}}*/
/*编译后的css文件*/
/*
ul li {
  width: 100%;
  height: 50px;
  border: 1px solid #000;
  font-size: 20px;
  color: #fff;
  background: red;
}
ul li:nth-child(5) {
  background: red;
}
ul li:nth-child(5) {
  background: red;
}
ul li:nth-child(5) {
  background: red;
}

 */
/*ul{
  li{
    width: 100%;
    height: 50px;
    border: 1px solid #000;
    font-size: 20px;
    color: #fff;
    background: red;
    
    	$i:5;
    	@while($i<=8)
    	{
    	&:nth-child(#{$i})
    	{
    		background: red;
    	}
    	$i:$i+1;
    }
    }*/
    /*编译后的css文件*/
    /*ul li {
  width: 100%;
  height: 50px;
  border: 1px solid #000;
  font-size: 20px;
  color: #fff;
  background: red;
}
ul li:nth-child(5) {
  background: red;
}
ul li:nth-child(6) {
  background: red;
}
ul li:nth-child(7) {
  background: red;
}
ul li:nth-child(8) {
  background: red;
}*/
	</style>
</head>
<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
    <li>10</li>
</ul>
<!--2.for循环
    @for $i from 起始整数 through 结束整数{}
    @for $i from 起始整数 to 结束整数{}
    两者的区别 through包头包尾, to包头不包尾

    3.while循环
    @while(条件语句){}
    */-->
</body>
</html>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/08/19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档