1. 程式人生 > 其它 >css3----------3D文字

css3----------3D文字

技術標籤:csscss

主要取決 text-shadow這個屬性

為什麼要在最後一次加陰影:為了使3D效果更強烈
為什麼要在第二層或者第三次加陰影:因為光線是找不到內部的

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <
title
>
Document</title> <style> * { padding: 0; margin: 0; } body { background-color: rgb(131, 156, 250); width: 100%; height: 100%; } h1 { margin: 20% auto; text-align: center; font-size: 5rem; color: white; text-transform
: uppercase; /*大寫*/ transition: 0.1s; } h1:hover{ text-shadow: 0 1px 0 #ccc, 0 1px 0 rgba(0, 0, 0, 0.2), 0 2px 0 #ccc, 0 2px 0 #ccc, 0 3px 0 #ccc, 0 4px 0 #ccc, 0 5px 0 #ccc, 0 6px 0 #ccc, 0 7px 0 #ccc, 0 8px 0 #ccc, 0 9px 0 #ccc, 0 10px 0 #ccc, 0 11px 0 #ccc, 0 12px 30px rgba
(0, 0, 0, 0.5); }
</style> </head> <body> <h1>3d text</h1> </body> </html>

在這裡插入圖片描述