【CSS案例】clip-path案例技巧

【CSS案例】clip-path案例技巧

圆形裁剪

圆形裁剪

/** 半径 at 圆心坐标X 圆心坐标Y */
clip-path: circle(50% at 100% 100%);

矩形裁剪

/** 类似于padding,参数方向:↑ → ↓ ← */
clip-path: inset(10% 20% 30% 40%);

椭圆裁剪

椭圆裁剪

/** 长轴(X方向) 短轴(Y方向) at 圆心坐标X 圆心坐标Y */
clip-path: ellipse(50% 25% at 50% 50%);

不规则裁剪

不规则形状裁剪

缩放效果

缩放效果

img {
	clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
	transition: .5s;
}
img:hover {
	clip-path: polygon(100% 0%, 100% 100%, 0% 100%, 0% 0%);
}

眨眼效果

眨眼效果

img {
	clip-path: ellipse(50% 20% at 50% 50%);
	transition: .5s;
	animation: wink 3s infinite;
}
@keyframes wink {
	15% {
		clip-path: ellipse(50% 1% at 50% 50%);
	}
	30% {
		clip-path: ellipse(50% 20% at 50% 50%);
	}
	45% {
		clip-path: ellipse(50% 1% at 50% 50%);
	}
	70% {
		clip-path: ellipse(50% 40% at 50% 50%);
	}
}

滑出效果

滑出效果

<div class="container">
	<h1>Hello World!</h1>
</div>
.container h1 {
	color: #fff;
	font-size: 5em;
	animation: slideDown 2s infinite;
}
@keyframes slideDown {
	from {
		clip-path: inset(100% 0% 0% 0%);
		transform: translateY(-100%);
	}
	to {
		clip-path: inset(0% 0% 0% 0%);
	}
}

箭头滑出效果

箭头滑出效果

<div class="img-box">
	<img src="1.jpeg"/>
	<img src="2.jpeg"/>
</div>
.img-box img {
	position: absolute;
	transition: .8s;
}

.img-box img:nth-child(2) {
	clip-path: polygon(-30% 0, -30% 0, 0 50%, -30% 100%, -30% 100%);
}

.img-box:hover img:nth-child(2){
	clip-path: polygon(-30% 0, 100% 0, 110% 50%, 100% 100%, -30% 100%);
}

聚光灯文字效果

聚光灯文字效果

<h1>HOLLOWORLD</h1>
h1 {
	color: #292929;
	font-size: 112px;
	position: relative;
}
h1::after {
	content: "HOLLOWORLD";
	/** 透明颜色 */
	color: transparent;
	position: absolute;
	top: 0;
	left: 0;
	background: linear-gradient(to right, #ff69b3, #fe0000, #ffa401, #ffff01, #008102, #40e1d2, #410098, #9400d4);
	/** 以文字范围裁剪背景图片 */
	background-clip: text;
	clip-path: circle(100px at 0% 50%);
	animation: light 5s infinite;
}
@keyframes light {
	0% {
		clip-path: circle(100px at 0% 50%);
	}
	50% {
		clip-path: circle(100px at 100% 50%);
	}
	100% {
		clip-path: circle(100px at 0% 50%);
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值