首页 > 其他分享 >HTML+CSS 生成跳动的心

HTML+CSS 生成跳动的心

时间:2024-06-09 21:55:59浏览次数:14  
标签:color 100px 跳动 height width HTML red background CSS

<!DOCTYPE html> <html lang="en">
<head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>跳动的心</title>
    <style>         * {             padding: 0;             margin: 0;         }
        /* 让容器的宽度和高度都充满全屏 */         html,         body {             width: 100%;             height: 100%;         }
        body {             background-color: pink;             display: flex;             flex-direction: row;             align-items: center;             justify-content: center;         }
        .heart {             width: 150px;             height: 150px;             background-color: red;             position: relative;             /* 将心旋转45° */             transform: rotate(45deg);             animation: heartBit 0.7s alternate infinite;             /* 添加阴影效果 (x , y 模糊度,阴影颜色) */             box-shadow: 0 0 30px red;         }         /* :before 选择器向选定元素的最后子元素后面插入内容。 */         .heart::before {             content: "";             width: 150px;             height: 100px;             background-color: red;             position: absolute;             left: 0;             /* 设置成-99 是为了防止让半圆与正方形进行重合后出现一条中间线 */             top: -99px;             /* 左上角.右上角,右下角.左下角 */             border-radius: 100px 100px 0 0;             box-shadow: 0 0 30px red;         }         /* :after 选择器向选定元素的最后子元素后面插入内容。 */         .heart::after {             content: "";             width: 100px;             height: 150px;             background-color: red;             position: absolute;             /* 设置成-99 是为了防止让半圆与正方形进行重合后出现一条中间线 */             left: -99px;             top: 0;             border-radius: 100px 0 0 100px;             box-shadow: 0 0 30px red;         }
        /* 实现动画效果.让心跳动起来 */         @keyframes heartBit {             0% {                 transform: rotate(45deg) scale(0.6);             }
            1000% {                 transform: rotate(45deg) scale(1);             }         }     </style> </head>
<body>
    <div class="heart"></div> </body>
</html>

翻译

搜索

复制

<iframe></iframe>

标签:color,100px,跳动,height,width,HTML,red,background,CSS
From: https://www.cnblogs.com/jw-t/p/18240084

相关文章

  • HTML+CSS生成滑动门
    <!DOCTYPEhtml><htmllang="en"><head>  <metacharset="UTF-8">  <metaname="viewport"content="width=device-width,initial-scale=1.0">  <title>滑动门</title>  &l......
  • 如何在html中插入背景图片
    在头标签<head></head>里,使用<style></style>标签,可以设置图片背景颜色、透明度等opacity的范围是0-1,数值越大,背景的透明度更低即页面更清晰<head><metacharset="UTF-8"><title>用户管理</title><style>body{backgro......
  • 大学生HTML期末大作业——HTML+CSS+JavaScript旅游网站(中山)
    HTML+CSS+JS【旅游网站】网页设计期末课程大作业web前端开发技术web课程设计网页规划与设计......
  • 大学生HTML期末大作业——HTML+CSS+JavaScript广东传统文化
    HTML+CSS+JS【传统文化】网页设计期末课程大作业web前端开发技术web课程设计网页规划与设计......
  • 初识HTML
    1.HTML基本结构在VSCode中,输入!即可生成一个基本的HTML结构:<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0">......
  • HTML 第一天
    标签语法<!--双标签--><strong>加粗</strong><!--单标签--><br><hr> 标签的关系<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metanam......
  • JavaScript html css 字符串对象
    字符串对象字符串所有的方法,都不会修改字符串本身(字符串是不可变的),操作完成会返回一个新的字符串。length属性作用:获取字符串长度示例:<spanstyle="background-color:#f8f8f8"><spanstyle="color:#333333"><spanstyle="color:#770088">let</span><spanstyle=......
  • uni-app 中使用 html2canvas 生成图片
    1.在项目中安装html2canvas插件npminstallhtml2canvas-D在需要生成图片的页面中引入html2canvas插件不过此时需要在页面中新建一个script节点,将lang属性设置为renderjs如对renderjs不了解,可看下uniapp官网的说明2.编写生成图片的代码<template><view......
  • Tailwindcss Layout布局相关样式及实战案例,5万字长文,附完整源码和效果截图
    aspect相关样式类基础样式ClassPropertiesaspect-autoaspect-ratio:auto;aspect-squareaspect-ratio:1/1;aspect-videoaspect-ratio:16/9;案例:引入B站视频Usetheaspect-*utilitiestosetthedesiredaspectratioofanelement.使用’aspect-*'实用工......
  • 大学生HTML期末大作业——HTML+CSS+JavaScript旅游网站(河南平顶山)
    HTML+CSS+JS【旅游网站】网页设计期末课程大作业web前端开发技术web课程设计网页规划与设计......