html+css 实现爱心跳动

前言:哈喽,大家好,今天给大家分享html+css 实现爱心跳动!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕


目录


📚💡📝🗂️✍️🛠️💻🚀🎉🏗️🌐🖼️🔗📊👉🔖⚠️🌟🔐⬇️·正文开始⬇️·🎥😊🎓📩😺🌈🤝🤖📜📖📋🔍✅🧰❓📄📢📈 🙋

📚一、效果

📚二、原理解析

💡1.这是一个,爱心跳动的效果。是一个div元素+2个伪元素组合实现的,如下图。

📝1.1 div是正方形。

📝1.2 before是圆形。

📝1.3after是另一个圆形。

💡3.具体的变换参数,直接看代码,可以一键复制,查看效果

📚三、上代码,可以直接复制使用

🗂️目录

✍️html

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>html+css 实现hover 实现爱心跳动</title>
    <link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="container">
    <h1 style="text-align: center;color:#fff;margin-bottom: 50px;padding-top: 100px; text-shadow: 0 3px 3px #4c6ed3;">
        html+css 实现爱心跳动</h1>

    <div class="wrapper">
        <div class="aiXin"></div>
    </div>
</div>

</body>
</html>

✍️css

css 复制代码
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --btn-bg-color: #fff;
    --font-color-black: #000;
    --btn-bg-color-hover: #FF5833;
}

.container {
    min-height: 100vh;
    background-color: #0e1538;
}

.wrapper {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

.aiXin{
    position: relative;
    width: 100px;
    height: 100px;
    transform: rotate(45deg);
    background-color: crimson;
    animation: aiXin 1s infinite;
}

/* 使用after和before伪元素来制作圆形的两边 */
.aiXin::after,.aiXin::before{
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: crimson;
    animation: aiXin 1s infinite;
}

.aiXin::after{
    top: 0px;
    left: -50px;
}

.aiXin::before{
    top: -50px;
    left: 0;
}

@keyframes aiXin{
    0%{
        width: 100px;
        height: 100px;
    }
    20%{
        width: 115px;
        height: 115px;
        background-color: #ef3953;
    }
    100%{
        width: 100px;
        height: 100px;
    }
}

到此这篇文章就介绍到这了,更多精彩内容请关注本人以前的文章或继续浏览下面的文章,创作不易,如果能帮助到大家,希望大家多多支持宝码香车~💕


更多专栏订阅推荐:

👍 html+css+js 绚丽效果

💕 vue

✈️ Electron

⭐️ js

📝 字符串

✍️ 时间对象(Date())操作

相关推荐
TimelessHaze24 分钟前
拆解字节面试题:async/await 到底是什么?底层实现 + 最佳实践全解析
前端·javascript·trae
执键行天涯1 小时前
从双重检查锁定的设计意图、锁的作用、第一次检查提升性能的原理三个角度,详细拆解单例模式的逻辑
java·前端·github
青青子衿越1 小时前
微信小程序web-view嵌套H5,小程序与H5通信
前端·微信小程序·小程序
OpenTiny社区1 小时前
TinyEngine 2.8版本正式发布:AI能力、区块管理、Docker部署一键强化,迈向智能时代!
前端·vue.js·低代码
qfZYG1 小时前
Trae 编辑器在 Python 环境缺少 Pylance,怎么解决
前端·vue.js·编辑器
bug爱好者1 小时前
Vue3 基于Element Plus 的el-input,封装一个数字输入框组件
前端·javascript
Silence_xl2 小时前
RACSignal实现原理
前端
柯南二号2 小时前
【大前端】实现一个前端埋点SDK,并封装成NPM包
前端·arcgis·npm
dangkei2 小时前
【Wrangler(Cloudflare 的官方 CLI)和 npm/npx 的区别一次讲清】
前端·jvm·npm
乔公子搬砖2 小时前
小程序开发提效:npm支持、Vant Weapp组件库与API Promise化(八)
前端·javascript·微信小程序·js·promise·vagrant·事件绑定