html+css好玩的案例
案例一
小块爬坡的的loading页面
效果图

css
*{
margin: 0;
padding: 0;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #333;
}
.cbody{
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
transform: rotate(-60deg);
}
.content{
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
-webkit-box-reflect: below 10px -webkit-linear-gradient(transparent,transparent 50%,rgba(255,255,255,0.6));
animation: donghua1 1.5s ease-in-out infinite;
}
@keyframes donghua1 {
0%{
transform:translateX(0);
}
100%{
transform:translateX(-200px);
}
}
.cure{
width: 200px;
height: 200px;
background-color: rgb(7, 198, 246);
box-shadow: 0 0 5px 5px rgb(24, 178, 216),
0 0 30px 15px rgba(26, 177, 214,0.5),
0 0 40px 25px rgba(26, 177, 214,0.5);
animation: donghua 1.5s ease-in-out infinite;
transform-origin: bottom right;
}
@keyframes donghua {
0%{
transform:rotate(0);
}
60%{
transform:rotate(90deg);
}
60%{
transform:rotate(85deg);
}
60%{
transform:rotate(90deg);
}
75%{
transform:rotate(87.5deg);
}
80%,100%{
transform: rotate(90deg);
}
}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>loading</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="cbody">
<div class="content">
<div class="cure"></div>
</div>
</div>
</body>
</html>
案例二
**
一个在三维下转动的环
**

css
*{
margin: 0;
padding: 0;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #333;
transform-style: preserve-3d;
}
.content{
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 500px;
perspective: 900px;
-webkit-box-reflect: below 10px -webkit-linear-gradient(transparent,transparent 50%,rgba(255,255,255,0.6));
/* //让总容器转动起来 */
/* animation: animation 5s linear infinite; */
}
/* @keyframes animation{
0%{
transform: rotateY(0);
filter: hue-rotate(0);
}
100%{
transform: rotateY(360deg);
filter: hue-rotate(360deg);
}
} */
span{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
border-radius: 50%;
border: 5px solid rgb(175, 51, 51);
box-shadow: 0 0 5px rgb(175, 51, 51),
0 0 25px rgba(175, 51, 51,.5);
/* //让小圈圈转动起来 */
animation: animation1 3s ease-in-out infinite;
}
@keyframes animation1{
0%{
transform: rotateY(0);
filter: hue-rotate(0);
}
100%{
transform: rotateY(360deg);
filter: hue-rotate(360deg);
}
}
span:nth-child(1){
width: 50px;
animation-delay: 0.1s;
}
span:nth-child(2){
width: 100px;
animation-delay: 0.2s;
}
span:nth-child(3){
width: 150px;
animation-delay: 0.3s;
}
span:nth-child(4){
width: 200px;
animation-delay: 0.4s;
}
span:nth-child(5){
width: 250px;
animation-delay: 0.5s;
}
span:nth-child(6){
width: 300px;
animation-delay: 0.6s;
}
span:nth-child(7){
width: 350px;
animation-delay: 0.7s;
}
span:nth-child(8){
width: 450px;
animation-delay: 0.8s;
}
span:nth-child(9){
width: 750px;
animation-delay: 0.9s;
}
span:nth-child(10){
width: 950px;
animation-delay: 1s;
}
span:nth-child(11){
width: 1250px;
animation-delay: 1.1s;
}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="content">
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
</div>
</body>
</html>
案例三:
符文圣地

css
* {
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
background-color: #333;
perspective: 900px;
}
.container {
height: 100%;
min-height: 100vh;
transform-style: preserve-3d;
}
p {
position: absolute;
top: 10%;
left: 50%;
-ms-writing-mode: tb-lr;
writing-mode: vertical-lr;
color: #e6f1e9;
transform: translateZ(10px);
text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #1ee928, 0 0 35px #1ee91e, 0 0 40px #1ee940,
0 0 50px #40e91e, 0 0 75px #1ee939;
-webkit-animation: move 10s linear infinite;
animation: move 10s linear infinite;
-webkit-box-reflect: below 77px -webkit-gradient(linear, left top, left bottom, from(transparent), to(rgba(250, 250, 250, 0.7)));
}
@-webkit-keyframes move {
10% {
transform: translateZ(-800px);
}
100% {
transform: translateZ(800px);
}
}
@keyframes move {
10% {
transform: translateZ(-800px);
}
100% {
transform: translateZ(800px);
}
}
p:nth-child(1) {
top: 10%;
left: 4%;
transform: translateZ(-400px);
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
p:nth-child(2) {
top: 10%;
left: 8%;
transform: translateZ(100px);
-webkit-animation-delay: 4s;
animation-delay: 4s;
}
p:nth-child(3) {
top: 9%;
left: 10%;
transform: translateZ(-100px);
-webkit-animation-delay: 0.5s;
animation-delay: 0.5s;
}
p:nth-child(4) {
top: 5%;
left: 15%;
transform: translateZ(300px);
-webkit-animation-delay: 1.2s;
animation-delay: 1.2s;
}
p:nth-child(5) {
top: 15%;
left: 20%;
transform: translateZ(10px);
-webkit-animation-delay: 3.2s;
animation-delay: 3.2s;
}
p:nth-child(6) {
top: 20%;
left: 30%;
transform: translateZ(0px);
-webkit-animation-delay: 4.2s;
animation-delay: 4.2s;
}
p:nth-child(7) {
top: 14%;
left: 40%;
transform: translateZ(30px);
-webkit-animation-delay: 2.9s;
animation-delay: 2.9s;
}
p:nth-child(8) {
top: 18%;
left: 44%;
transform: translateZ(100px);
-webkit-animation-delay: 1.5s;
animation-delay: 1.5s;
}
p:nth-child(9) {
top: 55%;
left: 50%;
transform: translateZ(-400px);
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
p:nth-child(10) {
top: 32%;
left: 53%;
transform: translateZ(-99px);
-webkit-animation-delay: 2.2s;
animation-delay: 2.2s;
}
p:nth-child(11) {
top: 43%;
left: 55%;
transform: translateZ(-250px);
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
p:nth-child(12) {
top: 21%;
left: 67%;
transform: translateZ(-590px);
-webkit-animation-delay: 0.5s;
animation-delay: 0.5s;
}
p:nth-child(13) {
top: 14%;
left: 77%;
transform: translateZ(626px);
-webkit-animation-delay: 3.2s;
animation-delay: 3.2s;
}
p:nth-child(14) {
top: 17%;
left: 80%;
transform: translateZ(-300px);
-webkit-animation-delay: 1.32s;
animation-delay: 1.32s;
}
p:nth-child(15) {
top: 34%;
left: 87%;
transform: translateZ(-120px);
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
p:nth-child(16) {
top: 30%;
left: 99%;
transform: translateZ(-220px);
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
p:nth-child(17) {
top: 25%;
left: 69%;
transform: translateZ(-33px);
-webkit-animation-delay: 0.6s;
animation-delay: 0.6s;
}
p:nth-child(18) {
top: 26%;
left: 49%;
transform: translateZ(-56px);
-webkit-animation-delay: 0.7s;
animation-delay: 0.7s;
}
p:nth-child(19) {
top: 57%;
left: 59%;
transform: translateZ(-743px);
-webkit-animation-delay: 0.8s;
animation-delay: 0.8s;
}
p:nth-child(20) {
top: 23%;
left: 29%;
transform: translateZ(-555px);
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
p:nth-child(21) {
top: 23%;
left: 55%;
transform: translateZ(-555px);
-webkit-animation-delay: 3.5s;
animation-delay: 3.5s;
}
p:nth-child(22) {
top: 23%;
left: 50%;
transform: translateZ(-555px);
-webkit-animation-delay: 4.1s;
animation-delay: 4.1s;
}
p:nth-child(23) {
top: 23%;
left: 29%;
transform: translateZ(-555px);
-webkit-animation-delay: 6.91s;
animation-delay: 6.91s;
}
p:nth-child(24) {
top: 23%;
left: 40%;
transform: translateZ(-555px);
-webkit-animation-delay: 5.21s;
animation-delay: 5.21s;
}
p:nth-child(25) {
top: 23%;
left: 60%;
transform: translateZ(-555px);
-webkit-animation-delay: 7.51s;
animation-delay: 7.51s;
}
p:nth-child(26) {
top: 23%;
left: 80%;
transform: translateZ(-555px);
-webkit-animation-delay: 7.1s;
animation-delay: 7.1s;
}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文字流动</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="container">
<p> ぁぃぅぇぉかきくけこんさしすせなにぬねのはひふへほゑまみむめもゃゅょゎを</p>
<p>ァィゥヴェォカヵキクケヶチツッテトヰンナニヌネノハムメモャュョヮヲ</p>
<p>ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすわゐゑをん</p>
<p>ぁあぃいぅうぇえぉおかがきぎくぐけ</p>
<p>どなにぬねのはばぱひびぴふけげこご</p>
<p>バパヒビピフブプヘベペホボポマ</p>
<p>ムメモャヤュユョヨラリルレけげこご</p>
<p>ただちぢっつづてでとすせなにぬねの</p>
<p>ニヌネノハバパヒすせなにぬねの</p>
<p>ぢっつづてでとどなにぬねけげこご</p>
<p>ぼぽまみむめもゃやゅゆょけげこご</p>
<p>∞Ψ ∪∩∈∏ の ℡ ぁ §∮”〃ミ灬ξ</p>
<p>至虚灵,至微妙。强称名,为大道。道之体,本自然。兆于一,象帝先。浑无物</p>
<p>辟混朦,渐微明。太无变,三分气。始青气,号清微。龙汉劫,天</p>
<p>元白气,号禹馀。显真文,焕太虚。玄黄气,号大赤。开上皇,万化孳。 </p>
<p>。十二部,度天人。建法筵,宝珠中。传经蕴,义无穷</p>
<p>我皇人,集云书。正天音,在劫初。译三洞,次四辅。七十二,冠古今。 </p>
<p>自玉清,至西那。玄风及,同顺化。けげこごけげこごけげこご</p>
<p>ずせぜそぞただちぢっつづぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎ</p>
<p>づてでとどなにぬねのはばぱひびぴふぶぷへけげこご</p>
<p>ムメモャヤュユョヨラリルレけげこご</p>
<p>ただちぢっつづてでとすせなにぬねの</p>
<p>ニヌネノハバパヒすせなにぬねの</p>
<p>ぢっつづてでとどなにぬねけげこご</p>
<p>ぼぽまみむめもゃやゅゆょけげこご</p>
<p>∞Ψ ∪∩∈∏ の ℡ ぁ §∮”〃ミ灬ξ</p>
</div>
</body>
</html>
案例四
3D 空间文字
css

* {
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #333;
}
p {
font-family: "Rajdhani", sans-serif;
font-weight: bold;
text-align: center;
display: block;
font-size: 16vh;
letter-spacing: 0.1em;
transform: rotateX(25deg) rotateY(-25deg);
text-shadow: 1px 1px rgba(226, 106, 126, 0.8), 3px 3px rgba(226, 106, 126, 0.7), 5px 5px rgba(226, 106, 126, 0.6),
7px 7px rgba(226, 106, 126, 0.5), 9px 9px rgba(226, 106, 126, 0.4);
-webkit-box-reflect: below 10px -webkit-gradient(linear, left top, left bottom, from(transparent), to(rgba(250, 250, 250, 0.7)));
}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./index.css">
<title>3D文字</title>
</head>
<body>
<p>CSS 3D</p>
<p>热血少年!!!</p>
</body>
</html>
案例五
css
clip-path 的 线条环绕(会动的)

div {
position: relative;
margin: 200px auto;
width: 120px;
line-height: 64px;
text-align: center;
color: #fff;
font-size: 20px;
border: 2px solid gold;
border-radius: 10px;
background: gold;
transition: all 0.3s;
cursor: pointer;
}
div::before,
div::after {
content: "";
position: absolute;
top: -40px;
left: -40px;
right: -40px;
bottom: -40px;
border: 4px solid gold;
animation: clippath 3s infinite linear;
border-radius: 10px;
}
div::after {
animation: clippath 3s infinite -1.5s linear;
}
@keyframes clippath {
0%,
100% {
clip-path: inset(0px 0px 0px 98%);
filter: hue-rotate(0deg);
}
25% {
clip-path: inset(0px 0px 98% 0);
filter: hue-rotate(90deg);
}
50% {
clip-path: inset(0px 98% 0px 0);
filter: hue-rotate(180deg);
}
75% {
clip-path: inset(98% 0px 0px 0);
filter: hue-rotate(270deg);
}
}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div>Hello</div>
</body>
</html>
案例六
hover 填充颜色

html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<ul>
<li style="--col:rgba(23, 35, 206, 0.8)" data-text=" never say dead "> never say dead </li>
<li style="--col:rgba(17, 230, 35, 0.8)" data-text=" try try try ! "> try try try ! </li>
<li style="--col:rgba(17, 180, 230, 0.8)" data-text=" perseverance "> perseverance </li>
<li style="--col:rgba(198, 17, 230, 0.8)" data-text=" just do it "> just do it </li>
<li style="--col:rgba(233, 18, 65, 0.8)" data-text=" do is encapsulate "> do is encapsulate </li>
</ul>
</body>
</html>
css
* {
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
background-color: #0c0b0b;
min-height: 100vh;
}
ul {
display: flex;
justify-content: center;
align-items: flex-start;
flex-direction: column;
gap: 40px;
list-style: none;
}
li {
position: relative;
font-size: 80px;
color: transparent;
height: 106px;
text-transform: uppercase;
white-space: nowrap;
-webkit-text-stroke: 1px #d7ddd6;
}
li::after {
content: attr(data-text);
display: inline-block;
position: absolute;
top: 0;
left: 0;
width: 0;
height: 106px;
color: var(--col);
overflow: hidden;
border-right: 5px solid var(--col);
transition: 1s linear;
text-transform: uppercase;
white-space: nowrap;
filter: drop-shadow(0 0 10px var(--col));
}
li:hover::after {
width: 100%;
cursor: pointer;
}
**
案例7
**
导航加载 雷达监测

html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="loading">
<span></span>
</div>
<div class="loading">
<span></span>
</div>
</body>
</html>
css
* {
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
background-color: #333;
min-height: 100vh;
}
.loading {
position: relative;
width: 400px;
height: 400px;
margin: 0 10px;
border-radius: 50%;
box-shadow: 25px 25px 50px rgba(22, 21, 21, 0.7);
background-color: rgba(37, 35, 35, 0.7);
overflow: hidden;
}
.loading::after {
content: "";
position: absolute;
inset: 77px;
border-radius: 50%;
border: 2px dashed #504a4a;
background-color: #333;
box-shadow: 0 0 10px #141111, inset 0 0 50px #141111;
}
.loading::before {
content: "";
position: absolute;
inset: 140px;
border-radius: 50%;
border: 2px dashed #504a4a;
background-color: #252424;
z-index: 10;
}
.loading span {
display: block;
position: absolute;
top: 50%;
left: 50%;
width: 200px;
height: 300px;
z-index: 99;
transform-origin: top left;
-webkit-animation: move 5s linear infinite;
animation: move 5s linear infinite;
filter: blur(17px);
overflow: hidden;
}
.loading span::after {
content: "";
display: block;
top: 0px;
left: 0px;
width: 200px;
height: 200px;
background-color: red;
transform-origin: top left;
transform: rotate(40deg);
filter: hue-rotate(200deg) blur(30px);
}
@-webkit-keyframes move {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
@keyframes move {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
.loading:nth-child(2) span {
-webkit-animation-delay: 1.5s;
animation-delay: 1.5s;
}
案例8
灯光效果的导航按钮 +倒影效果


html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="./index.css">
</head>
<body>
<ul>
<li style="--color:rgb(235, 41, 41)">
<a href="#"><i class="fa fa-cog" aria-hidden="true"></i></a>
</li>
<li style="--color:rgb(47, 231, 22)">
<a href="#"><i class="fa fa-commenting" aria-hidden="true"></i></a>
</li>
<li style="--color:rgb(15, 191, 235)">
<a href="#"><i class="fa fa-envelope" aria-hidden="true"></i></a>
</li>
<li style="--color:rgb(235, 23, 199)">
<a href="#"><i class="fa fa-heartbeat" aria-hidden="true"></i></a>
</li>
</ul>
</body>
</html>
css
* {
margin: 0;
padding: 0;
}
:root {
--col: #333;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: var(--col);
}
ul {
list-style: none;
display: flex;
justify-content: center;
align-items: center;
gap: 40px;
}
ul li {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 70px;
height: 70px;
-webkit-box-reflect: below 10px -webkit-gradient(linear, left top, left bottom, from(transparent), to(rgba(250, 250, 250, 0.7)));
}
ul li a {
display: block;
text-decoration: none;
text-align: center;
width: 70px;
height: 70px;
font-size: 40px;
line-height: 70px;
z-index: 9;
}
ul li a i {
transition: 0.5s linear;
color: var(--color);
transform: scale(0.7);
}
ul li::before {
content: "";
position: absolute;
display: block;
inset: 25px;
box-shadow: 0 0 0 5px var(--color), 0 0 0 12px var(--col), 0 0 0 14px var(--color);
transition: 0.5s linear;
}
ul li::after {
content: "";
position: absolute;
display: block;
inset: 10px;
background-color: var(--col);
transform: rotate(45deg);
transition: 0.5s linear;
}
ul li:hover::after {
inset: 12px;
filter: drop-shadow(0 0 5px var(--color));
}
ul li:hover::before {
inset: 5px;
filter: drop-shadow(0 0 5px var(--color));
}
ul li:hover a i {
transform: scale(1);
filter: drop-shadow(0 0 5px var(--color));
}
本文展示了多个使用HTML和CSS创作的创意案例,包括3D空间文字、线条环绕动画、灯光效果导航等。通过源码分享,读者可以学习到如何实现这些有趣的视觉效果。

335

被折叠的 条评论
为什么被折叠?



