CSS3 线性渐变色(linear-gradient)

55 篇文章 1 订阅
34 篇文章 0 订阅


demo.html:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>

		div {
			width: 1000px;
			height: 100px;
			border: 1px solid #000;
			margin: 5px auto;
		}

		/* 线性渐变色 */
		div:nth-child(1) {
			background: linear-gradient(to right, yellow, blue);  /* 方向(默认从上到下),起始颜色,终止颜色 */
		}

		div:nth-child(2) {
			background: linear-gradient(yellow, blue);  /* 方向(默认从上到下) */
		}

		div:nth-child(3) {
			width: 200px;
			height: 200px;
			background: linear-gradient(45deg, yellow, blue);  /* 方向可以是角度 */
		}

		div:nth-child(4) {
			background: linear-gradient(to right, yellow 0%, red 40%, green 70%,blue 100%);  /* 多种颜色,百分比表示渐变线上的位置 */
		}

		div:nth-child(5) {
			background: linear-gradient(45deg, yellow 0%, yellow 25%, red 25%, red 50%, green 50%, green 75%, blue 75%, blue 100%);  /* 多种颜色,百分比表示渐变线上的位置 */
		}

		/* 斑马线效果 */
		div:nth-child(6) {
			background: linear-gradient(45deg, #000 0%, #000 25%, #fff 25%, #fff 50%, #000 50%, #000 75%, #fff 75%, #fff 100%);
			/*background-repeat: no-repeat;*/  /* 默认会平铺 */
			background-size: 99px 100%;   /* 控制显示区域大小,然后平铺 */
		}

	</style>
</head>
<body>
	<div class="box"></div>
	<div class="box"></div>
	<div class="box"></div>
	<div class="box"></div>
	<div class="box"></div>
	<div class="box"></div>
</body>
</html>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值