CSS实现3D文字

3D文字

方式一:使用text-shadow

通过text-shadow属性,对文字逐层设置多个阴影,达到3D效果:

<style>
.hollow-text {
  font-size: 100px;
  font-weight: bold;
  color: #fff;
  text-shadow: 
	1px 1px 0 #ccc, 
	2px 2px 0 #ccc, 
	3px 3px 0 #ccc, 
	4px 4px 0 #ccc, 
	5px 5px 0 #ccc;
}
</style>

<body>
<div class="hollow-text">3D文字</div>
<div class="hollow-text">HELLO WORLD</div>
</body>

text-shadow实现3D文字

方式二:使用 transform

通过transform属性进行3D变换,达到视觉上的3D效果:

<style>
.hollow-text {
	font-size: 100px;
	font-weight: bold;
	color: #fff;
	background: #333;
	transform: perspective(1000px) rotateX(60deg); /* 增加透视距离和旋转角度 */
	transform-origin: 50% 100%; /* 设置变换原点 */
	text-shadow: 10px 10px 0 #000; /* 增加一点阴影,使效果更明显 */
}
</style>

<body>
<div class="hollow-text">3D文字</div>
<div class="hollow-text">HELLO WORLD</div>
</body>

 transform实现3D

方式三:使用box-shadow

使用box-shadow属性,可以模拟文字投影,再结合 transform 进行 3D 变换,也可以达到3D效果:

<style>
.hollow-text {
	font-size: 100px;
	font-weight: bold;
	color: #333;
	transform: perspective(300px) rotateX(25deg);
	transform-origin: 50% 100%;
	box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}
</style>

<body>
<div class="hollow-text">3D文字</div>
<div class="hollow-text">HELLO WORLD</div>
</body>

box-shadow实现3D

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值