CSS3 骨折文字

在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
<title>Fracture Text</title>
<meta charset="utf8">
<style>
body {
	background: WhiteSmoke;
}
#fractureText {
	color: black;
	
	/**
	vw/vh指的是相对视口(即浏览器窗口的百分比大小)
	*/
	font-size: 5vw;
	
	/**
	字体粗细,100-900。
	400等同于normal,700等同于bold。
	*/
	font-weight: bold;
	
	/**
	设置如何处理元素中的空白
	normal		默认,空白会被浏览器忽略
	pre			空白会被浏览器保留,类似<pre>标签
	nowrap		不换行,除非遇到<br>标签
	pre-wrap	保留空白符序列,保留换行符
	pre-line	合并空白序列,保留换行符
	inherit		从父元素继承
	*/
	white-space: nowrap;
	
	/**
	控制文本的大小写
	none		不做处理
	capitalize	文本中的每个单词以大写字母开头
	uppercase	所有字母转为大写
	lowercase	所有字母转为小写
	inherit		从父元素继承
	*/
	text-transform: uppercase;
	
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	
	/**
	z-index 元素的堆叠顺序。正数离用户更近,负数更远
	z-index 仅能在绝对定位中有效
	*/
	z-index: 1;
}
#fractureText:before, #fractureText:after {
	/**
	伪元素必须声明content,否则无法显示
	*/
	content: attr(data-text);
	
	position: absolute;
	left: 0;
	width: 100%;
}
#fractureText:before {
	color: white;
	background: white;
	
	/**
	对元素进行剪裁,仅显示该区域的内容。
	这里是剪裁成一个多边形
	*/
	clip-path: polygon(0 0, 100% 0%, 100% 45%, 0 60%);
	
	z-index: 2;
}
#fractureText:after {
	color: black;
	clip-path: polygon(0 0, 100% 0%, 100% 42%, 0 57%);
	/**
	animation-name				动画名称(配合@keyframes使用)
	animation-duration			动画持续时间
	
	animation-timing-function	动画过渡类型
								linear			线性过度
								ease 			平滑过渡
								ease-in			由慢到快
								ease-out		由快到慢
								ease-in-out		由慢到快又变慢
								steps(n, start/end)	阶跃函数,
													第一个参数表示将动画分为几段,
													第二个参数表示阶跃的时机。
								step-start		等同于steps(1, start); 
								step-end		等同于steps(1, end); 
								cubic-bezier	两个控制点的贝塞尔曲线
								
	animation-delay				动画延迟
	animation-iteration-count	动画循环次数(infinite,表示循环播放)
	
	animation-direction			动画正放(normal)还是倒放(alternate)
								normal				正常播放
								reverse				反向播放
								alternate			动画在奇数次(1、3、5...)正向播放,在偶数次(2、4、6...)反向播放
								alternate-reverse	动画在奇数次(1、3、5...)反向播放,在偶数次(2、4、6...)正向播放
								initial				保持其初始值
								inherit				从父元素继承
							
	animation-fill-mode			动画不播放时的状态
								none 		不改变默认行为
								forwards 	当动画完成后,保持最后一个属性值
								backwards 	在animation-delay所指定的一段时间内,在动画显示之前,应用开始属性值
								both 		向前和向后填充模式都被应用
								
	animation-play-state		动画播放(running)和暂停(paused)
	*/
	animation: fracture 3s infinite ease;
	z-index: 3;
	
	/**
	可以同时设置多对阴影,中间用逗号隔开即可
	*/
	text-shadow: -3px -3px 5px gray;
}
@keyframes fracture {
	0% {
		transform: translateX(0);
	}
	50% {
		transform: translate(-2vw, 3%);
	}
}
</style>
</head>
<body>
<div id="fractureText" contenteditable data-text="III Fracture Text">III Fracture Text</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值