渐变

线性渐变

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>线性渐变</title>
        <style>
            .border1{
                width: 200px;
                height: 200px;
				margin: 100px;
                position: relative;
                border-radius:200px;
                background: white;
            }
            .border1::after{
                position: absolute;
                top: -40px; 
                bottom: -40px;
                left: -40px;
                right: -40px;
                background: linear-gradient(to right,blue, yellow);
                content: '';
                z-index: -1;
                border-radius: 200px;
            }

        </style>
    </head>
    <body>    
		
        <div class="border1"></div>

    </body>
</html>

旋转渐变

<!DOCTYPE html>
<html>
	<head>
		<title>旋转渐变</title>
		<style>
			@keyframes moveover {
				0% {
					transform: rotate(0deg);
				}

				100% {
					transform: rotate(360deg);
				}
			}

			.box {
				position: relative;
				width: 100px;
				height: 100px;
				/*整体旋转*/
				animation: moveover 3s linear infinite;
			}

			.box::before {
				content: "";
				position: absolute;
				width: 50px;
				height: 100px;
				border-radius: 50px 0 0 50px;
				background: linear-gradient(blue, yellow);
				z-index: 2;
			}

			.box2 {
				position: absolute;
				width: 50px;
				height: 100px;
				border-radius: 0 50px 50px 0;
				left: 50%;
				background: linear-gradient(blue, yellow);
				z-index: 1;
			}

			.box::after {
				content: "";
				position: absolute;
				width: 92px;
				height: 92px;
				top: 4px;
				left: 4px;
				border-radius: 50%;
				background-color: #fff;
				z-index: 2;
			}
		</style>
	</head>
	<body>
		<div class='box'>
			<div class="box2"></div>
		</div>
	</body>
</html>

背景渐变是一种在网页设计中常用的效果,它可以使背景色从一种颜色平滑过渡到另一种颜色,创建出丰富多彩的视觉效果。背景渐变可以通过CSS的线性渐变(linear gradient)或径向渐变(radial gradient)来实现。 1. 线性渐变:线性渐变是指背景色在一个方向上从一种颜色过渡到另一种颜色。可以通过设置起点和终点的位置、颜色和过渡方式来定义线性渐变。例如,可以从上到下或从左到右创建一个渐变效果。 2. 径向渐变:径向渐变是指背景色从一个中心点向外辐射状地过渡到另一种颜色。可以通过设置中心点的位置、颜色和过渡方式来定义径向渐变。例如,可以从内向外或从外向内创建一个渐变效果。 在CSS中,可以使用以下代码来创建线性渐变和径向渐变的背景效果: 1. 线性渐变的示例代码: ```css background: linear-gradient(direction, color-stop1, color-stop2, ...); ``` 其中,direction表示渐变的方向,可以是角度(如45deg表示从左上角到右下角)或关键词(如to bottom表示从上到下);color-stop表示颜色的位置和值,可以是具体的颜色值或关键词(如transparent表示透明)。 2. 径向渐变的示例代码: ```css background: radial-gradient(shape size at position, start-color, ..., last-color); ``` 其中,shape表示渐变的形状,可以是圆形(circle)或椭圆形(ellipse);size表示渐变的大小,可以是具体的长度值或关键词(如closest-side表示最近边);position表示渐变的中心点位置,可以是具体的坐标值或关键词(如center表示居中);start-color和last-color表示起始和结束的颜色。 以上是背景渐变的简要介绍,如果你有更具体的问题或需要进一步了解,请告诉我。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值