大数跨境
0
0

可爱小狗发射爱心(附源码)

可爱小狗发射爱心(附源码) 码途钥匙
2024-08-21
1
导读:可爱小狗发射爱心(附源码)

点击上方 【蓝字】 关注我们

可爱小狗发射爱心效果图



HTML


     
     
     

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>谁说柯基不算爱心呢</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" />
<style>
/* 这里是 CSS 样式定义,下面会详细解释 */
</style>
</head>
<body>
<div class="dog">
<!-- 这里是柯基图形的各个部分 -->
</div>
</body>
</html>




CSS

     
     
     

html, body {
/* 设置背景相关属性,如重复方式、尺寸、位置、布局、颜色等 */
background-repeat: no-repeat;
background-size: contain;
background-position: center center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #3f3456;
background-size: fill;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}

.dog {
/* 柯基整体图形的定位和尺寸设置 */
position: absolute;
top: 52%;
width: 50vmin;
height: 40vmin;
z-index: 0;
}

.heart {
/* 爱心图形的基本样式,如尺寸、颜色、圆角、透明度等 */
position: absolute;
width: 6%;
height: 7%;
background-color: #e64356;
border-bottom-right-radius: 23%;
opacity: 0;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}

/* 爱心的动画关键帧定义 */
@-webkit-keyframes heart-beat {
/* 不同阶段的爱心变换效果 */
}
@keyframes heart-beat {
/* 不同阶段的爱心变换效果 */
}

/* 不同的爱心实例分别应用不同的动画设置和位置调整 */
.heart--1 {
/* 位置和动画设置 */
}
.heart--2 {
/* 位置和动画设置 */
}
.heart--3 {
/* 位置和动画设置 */
}
.heart--4 {
/* 位置和动画设置 */
}

.heart:before,.heart:after {
/* 爱心的伪元素设置,用于创建更多形状 */
}

.body {
/* 柯基身体的样式设置,如颜色、圆角等 */
position: absolute;
width: 100%;
height: 50%;
background-color: #f79e38;
border-top-right-radius: 17% 40%;
border-top-left-radius: 25%;
border-bottom-right-radius: 5% 13%;
border-bottom-left-radius: 30% 40%;
z-index: 3;
}

.cheast {
/* 柯基胸部的样式设置 */
position: absolute;
width: 45%;
height: 100%;
background-color: #fff;
border-top-right-radius: 17% 40%;
border-top-left-radius: 25%;
border-bottom-right-radius: 40% 40%;
border-bottom-left-radius: 40% 40%;
z-index: 4;
}

.cheast:after,.cheast:before {
/* 胸部的伪元素设置 */
}

.head {
/* 柯基头部的样式和动画设置 */
position: absolute;
width: 100%;
height: 100%;
z-index: 4;
-webkit-animation: dog-head 1s ease-out infinite;
animation: dog-head 1s ease-out infinite;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}

/* 头部动画的关键帧定义 */
@-webkit-keyframes dog-head {
/* 头部动画效果 */
}
@keyframes dog-head {
/* 头部动画效果 */
}

.tail {
/* 柯基尾巴的样式、位置、动画设置 */
position: absolute;
top: -14%;
left: 92%;
width: 10%;
height: 45%;
background-color: #f79e38;
border-top-right-radius: 30% 30%;
border-top-left-radius: 40% 30%;
border-bottom-right-radius: 30% 40%;
border-bottom-left-radius: 40% 40%;
z-index: 2;
transform: rotate(20deg);
-webkit-animation: dog-tail 170ms ease-out infinite;
animation: dog-tail 170ms ease-out infinite;
}

/* 尾巴动画的关键帧定义 */
@-webkit-keyframes dog-tail {
/* 尾巴动画效果 */
}
@keyframes dog-tail {
/* 尾巴动画效果 */
}

.tail:before {
/* 尾巴的伪元素设置及动画定义 */
}

.legs {
/* 柯基腿部的整体样式和动画设置 */
position: absolute;
top: 97%;
left: 0;
width: 100%;
height: 30%;
z-index: 2;
-webkit-animation: dog-legs 1s ease-out infinite 1.5s;
animation: dog-legs 1s ease-out infinite 1.5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}

/* 腿部动画的关键帧定义 */
@-webkit-keyframes dog-legs {
/* 腿部动画效果 */
}
@keyframes dog-legs {
/* 腿部动画效果 */
}

.legs__front,.legs__back {
/* 柯基腿部的基本样式设置 */
}

.legs__front:after,.legs__back:after {
/* 腿部的伪元素设置 */
}

.legs__front--left {
/* 左前腿的位置和旋转设置 */
}
.legs__front--right {
/* 右前腿的位置和旋转设置 */
}
.legs__back--left {
/* 左后腿的位置和旋转设置 */
}
.legs__back--right {
/* 右后腿的位置和旋转设置 */
}

.face {
/* 柯基脸部的样式设置 */
height: 40%;
width: 42%;
position: absolute;
top: -13%;
left: -3%;
background-color: #fff;
border-top-right-radius: 45% 50%;
border-top-left-radius: 35% 50%;
border-bottom-left-radius: 35% 21%;
z-index: 6;
}

.face:after,.face:before {
/* 脸部的伪元素设置 */
}

.eye {
/* 柯基眼睛的样式和动画设置 */
width: 6%;
height: 6%;
position: absolute;
border-radius: 100%;
top: 24%;
background-color: #000;
z-index: 6;
-webkit-animation: dog-eye 1800ms infinite;
animation: dog-eye 1800ms infinite;
}

/* 眼睛动画的关键帧定义 */
@-webkit-keyframes dog-eye {
/* 眼睛动画效果 */
}
@keyframes dog-eye {
/* 眼睛动画效果 */
}

.eye--left {
/* 左眼的位置设置 */
}
.eye--right {
/* 右眼的位置设置 */
}

.mouth {
/* 柯基嘴巴的样式设置 */
}

.year {
/* 柯基耳朵的整体样式设置 */
}

.year--left {
/* 左耳的位置、样式和动画设置 */
}

/* 左耳动画的关键帧定义 */
@-webkit-keyframes left-year {
/* 左耳动画效果 */
}
@keyframes left-year {
/* 左耳动画效果 */
}

.year--right {
/* 右耳的位置、样式和动画设置 */
}

/* 右耳动画的关键帧定义 */
@-webkit-keyframes right-year {
/* 右耳动画效果 */
}
@keyframes right-year {
/* 右耳动画效果 */
}

.nose {
/* 柯基鼻子的样式设置 */
}

.nose:after {
/* 鼻子的伪元素设置 */
}

这段 CSS 代码通过复杂的样式定义和动画效果,创建了一个可爱的柯基图形,包括身体、头部、尾巴、腿部、眼睛、嘴巴、耳朵和鼻子等部分,并为这些部分添加了各种动画效果,使柯基图形更加生动。


完整代码

   
   
   

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>谁说柯基不算爱心呢</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"
/>
<style>
html,
body {
background-repeat: no-repeat;
background-size: contain;
background-position: center center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #3f3456;
background-size: fill;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.dog {
position: absolute;
top: 52%;
width: 50vmin;
height: 40vmin;
z-index: 0;
}
.heart {
position: absolute;
width: 6%;
height: 7%;
background-color: #e64356;
border-bottom-right-radius: 23%;
opacity: 0;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes heart-beat {
0% {
transform: scale(0.75) rotate(35deg);
opacity: 1;
}
5%,
15%,
25% {
transform: scale(1) rotate(35deg);
}
10%,
20% {
transform: scale(0.75) rotate(35deg);
}
70% {
opacity: 1;
}
100% {
transform: rotate(35deg) translateY(-10px) translateX(-10px);
opacity: 0;
}
}
@keyframes heart-beat {
0% {
transform: scale(0.75) rotate(35deg);
opacity: 1;
}
5%,
15%,
25% {
transform: scale(1) rotate(35deg);
}
10%,
20% {
transform: scale(0.75) rotate(35deg);
}
70% {
opacity: 1;
}
100% {
transform: rotate(35deg) translateY(-10px) translateX(-10px);
opacity: 0;
}
}
.heart--1 {
top: -25%;
left: 15%;
-webkit-animation: heart-beat 2s ease-out infinite 1.5s;
animation: heart-beat 2s ease-out infinite 1.5s;
}
.heart--2 {
top: -36%;
left: 7%;
-webkit-animation: heart-beat 2s ease-out infinite 1s;
animation: heart-beat 2s ease-out infinite 1s;
}
.heart--3 {
top: -48%;
left: 14%;
-webkit-animation: heart-beat 2s ease-out infinite 0.5s;
animation: heart-beat 2s ease-out infinite 0.5s;
}
.heart--4 {
top: -53%;
left: -3%;
-webkit-animation: heart-beat 2s ease-out infinite;
animation: heart-beat 2s ease-out infinite;
}
.heart:before,
.heart:after {
position: absolute;
width: 100%;
height: 100%;
content: '';
border-radius: 50%;
background-color: #e64356;
}
.heart:after {
bottom: 0px;
left: -53%;
}
.heart:before {
top: -53%;
right: 0px;
transform: rotate(45deg);
}
.body {
position: absolute;
width: 100%;
height: 50%;
background-color: #f79e38;
border-top-right-radius: 17% 40%;
border-top-left-radius: 25%;
border-bottom-right-radius: 5% 13%;
border-bottom-left-radius: 30% 40%;
z-index: 3;
}
.cheast {
position: absolute;
width: 45%;
height: 100%;
background-color: #fff;
border-top-right-radius: 17% 40%;
border-top-left-radius: 25%;
border-bottom-right-radius: 40% 40%;
border-bottom-left-radius: 40% 40%;
z-index: 4;
}
.cheast:after,
.cheast:before {
position: absolute;
content: '';
width: 7%;
height: 55%;
border-radius: 39%;
background-color: #fff;
}
.cheast:after {
top: 36%;
left: 3%;
transform: rotate(-1deg);
}
.cheast:before {
top: 19%;
left: -4%;
}
.head {
position: absolute;
width: 100%;
height: 100%;
z-index: 4;
-webkit-animation: dog-head 1s ease-out infinite;
animation: dog-head 1s ease-out infinite;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}
@-webkit-keyframes dog-head {
to {
transform: translateX(-3px) rotate(3deg);
}
}
@keyframes dog-head {
to {
transform: translateX(-3px) rotate(3deg);
}
}
.tail {
position: absolute;
top: -14%;
left: 92%;
width: 10%;
height: 45%;
background-color: #f79e38;
border-top-right-radius: 30% 30%;
border-top-left-radius: 40% 30%;
border-bottom-right-radius: 30% 40%;
border-bottom-left-radius: 40% 40%;
z-index: 2;
transform: rotate(20deg);
-webkit-animation: dog-tail 170ms ease-out infinite;
animation: dog-tail 170ms ease-out infinite;
}
@-webkit-keyframes dog-tail {
from,
to {
transform: rotate(10deg);
}
50%,
60% {
transform: rotate(70deg) translateX(10px) translateY(2px);
}
}
@keyframes dog-tail {
from,
to {
transform: rotate(10deg);
}
50%,
60% {
transform: rotate(70deg) translateX(10px) translateY(2px);
}
}
.tail:before {
position: absolute;
content: '';
top: -8%;
left: -7%;
width: 100%;
height: 50%;
background-color: #f79e38;
border-radius: 50%;
-webkit-animation: dog-tail-before 160ms ease-out infinite;
animation: dog-tail-before 160ms ease-out infinite;
}
@-webkit-keyframes dog-tail-before {
from,
to {
transform: translateX(0);
}
50% {
transform: translateX(3px);
}
}
@keyframes dog-tail-before {
from,
to {
transform: translateX(0);
}
50% {
transform: translateX(3px);
}
}
.legs {
position: absolute;
top: 97%;
left: 0;
width: 100%;
height: 30%;
z-index: 2;
-webkit-animation: dog-legs 1s ease-out infinite 1.5s;
animation: dog-legs 1s ease-out infinite 1.5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}
@-webkit-keyframes dog-legs {
from {
transform: translateY(-1px);
}
to {
transform: translateY(0px);
}
}
@keyframes dog-legs {
from {
transform: translateY(-1px);
}
to {
transform: translateY(0px);
}
}
.legs__front,
.legs__back {
width: 10%;
height: 100%;
background-color: #f79e38;
position: absolute;
border-bottom-right-radius: 100%;
border-bottom-left-radius: 100%;
}
.legs__front:after,
.legs__back:after {
content: '';
position: absolute;
top: 50%;
width: 100%;
height: 49%;
background-color: #fff;
border-bottom-right-radius: 100%;
border-bottom-left-radius: 100%;
}
.legs__front--left {
left: 38%;
transform: rotate(1deg);
}
.legs__front--right {
left: 20%;
transform: rotate(-4deg);
}
.legs__back--left {
left: 69%;
transform: rotate(-7deg);
}
.legs__back--right {
left: 85%;
transform: rotate(2deg);
}
.face {
height: 40%;
width: 42%;
position: absolute;
top: -13%;
left: -3%;
background-color: #fff;
border-top-right-radius: 45% 50%;
border-top-left-radius: 35% 50%;
border-bottom-left-radius: 35% 21%;
z-index: 6;
}
.face:after,
.face:before {
content: '';
position: absolute;
background-color: #f79e38;
}
.face:after {
width: 27%;
left: 7%;
height: 23%;
border-top-right-radius: 100% 100%;
border-bottom-left-radius: 49% 100%;
transform: rotate(-64deg);
top: -1%;
border-top-left-radius: 0% -20%;
border-bottom-right-radius: 52% 0%;
box-shadow: rgba(0, 0, 0, 0.1) 2px -6px 11px 1px;
}
.face:before {
width: 55%;
left: 42%;
top: 0%;
height: 35%;
border-radius: 23% 7% 16% 12%;
transform: rotate(0deg) scaleX(-1);
}
.eye {
width: 6%;
height: 6%;
position: absolute;
border-radius: 100%;
top: 24%;
background-color: #000;
z-index: 6;
-webkit-animation: dog-eye 1800ms infinite;
animation: dog-eye 1800ms infinite;
}
@-webkit-keyframes dog-eye {
from,
to {
-webkit-animation-timing-function: step-end;
animation-timing-function: step-end;
opacity: 1;
}
50%,
55% {
-webkit-animation-timing-function: step-start;
animation-timing-function: step-start;
opacity: 0;
}
}
@keyframes dog-eye {
from,
to {
-webkit-animation-timing-function: step-end;
animation-timing-function: step-end;
opacity: 1;
}
50%,
55% {
-webkit-animation-timing-function: step-start;
animation-timing-function: step-start;
opacity: 0;
}
}
.eye--left {
left: 27%;
}
.eye--right {
left: 46%;
}
.mouth {
background-color: transparent;
border-color: #000;
width: 44%;
border-style: solid;
border-width: 0.7vmin;
height: 48%;
z-index: 6;
position: absolute;
bottom: 35%;
left: 14%;
border-top-color: transparent;
border-bottom-left-radius: 72% 100%;
border-bottom-right-radius: 77% 100%;
border-right-color: transparent;
border-top-right-radius: 50%;
border-left-color: transparent;
transform: rotate(-41deg);
}
.year {
position: absolute;
}
.year--left {
top: -40%;
left: 3%;
height: 47%;
width: 19%;
z-index: 1;
background-color: #e99036;
border-top-left-radius: 68% 100%;
border-top-right-radius: 100% 100%;
transform-origin: bottom center;
-webkit-animation: left-year 1000ms ease-out infinite;
animation: left-year 1000ms ease-out infinite;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}
@-webkit-keyframes left-year {
from {
transform: rotate(-26deg);
}
25% {
transform: rotate(-35deg);
}
50% {
transform: rotate(-26deg);
}
to {
transform: rotate(-40deg);
}
}
@keyframes left-year {
from {
transform: rotate(-26deg);
}
25% {
transform: rotate(-35deg);
}
50% {
transform: rotate(-26deg);
}
to {
transform: rotate(-40deg);
}
}
.year--right {
top: -39%;
left: 19%;
height: 38%;
width: 18%;
z-index: 1;
background-color: #f79e38;
border-top-left-radius: 56% 100%;
border-top-right-radius: 100% 100%;
transform-origin: bottom center;
border-bottom-right-radius: 14% 38%;
-webkit-animation: right-year 1000ms ease-out infinite;
animation: right-year 1000ms ease-out infinite;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}
@-webkit-keyframes right-year {
from {
transform: rotate(-331deg);
}
25% {
transform: rotate(-320deg);
}
50% {
transform: rotate(-331deg);
}
to {
transform: rotate(-320deg);
}
}
@keyframes right-year {
from {
transform: rotate(-331deg);
}
25% {
transform: rotate(-320deg);
}
50% {
transform: rotate(-331deg);
}
to {
transform: rotate(-320deg);
}
}
.nose {
position: absolute;
width: 24%;
height: 24%;
background-color: #fff;
z-index: 7;
left: -12%;
top: -3%;
border-bottom-left-radius: 50% 88%;
border-top-left-radius: 11% 43%;
transform: rotate(12deg);
}
.nose:after {
content: '';
position: absolute;
width: 50%;
height: 55%;
background-color: #000;
border-radius: 100%;
left: -7%;
top: -18%;
}
</style>
</head>
<body>
<div class="dog">
<div class="heart heart--1"></div>
<div class="heart heart--2"></div>
<div class="heart heart--3"></div>
<div class="heart heart--4"></div>
<div class="head">
<div class="year year--left"></div>
<div class="year year--right"></div>
<div class="nose"></div>
<div class="face">
<div class="eye eye--left"></div>
<div class="eye eye--right"></div>
<div class="mouth"></div>
</div>
</div>
<div class="body">
<div class="cheast"></div>
<div class="back"></div>
<div class="legs">
<div class="legs__front legs__front--left"></div>
<div class="legs__front legs__front--right"></div>
<div class="legs__back legs__back--left"></div>
<div class="legs__back legs__back--right"></div>
</div>
<div class="tail"></div>
</div>
</div>
</body>
</html>
Copy


√完整版代码
1.关注公众号
2.后台留言”可爱小狗“即可




【声明】内容源于网络
0
0
码途钥匙
欢迎来到 Python 学习乐园!这里充满活力,分享前沿实用知识技术。新手或开发者,都能找到价值。一起在这个平台,以 Python 为引,开启成长之旅,探索代码世界,共同进步。携手 Python,共赴精彩未来,快来加入我们吧!
内容 992
粉丝 0
码途钥匙 欢迎来到 Python 学习乐园!这里充满活力,分享前沿实用知识技术。新手或开发者,都能找到价值。一起在这个平台,以 Python 为引,开启成长之旅,探索代码世界,共同进步。携手 Python,共赴精彩未来,快来加入我们吧!
总阅读391
粉丝0
内容992