当前位置: 首页 > news >正文

CSS画圆以及CSS实现动态圆

CSS画圆以及CSS实现动态圆

  • 1. 先看基础(静态圆)
    • 1.1 效果如下:
    • 1.2 代码如下:
  • 2. 动态圆
    • 2.1 一个动态圆
      • 2.1.1 让圆渐变
      • 2.1.2 圆渐变8秒后消失
      • 2.1.3 转动的圆(单个圆)
    • 2.2 多个动态圆

1. 先看基础(静态圆)

1.1 效果如下:

  • 如下:
    在这里插入图片描述

1.2 代码如下:

  • 如下:

    <!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>/* 正方形 */.xmbook_red_point_1 {width: 50px;height: 50px;display: inline-block;background-color: red;}/* 圆角正方形 */.xmbook_red_point_2 {width: 50px;height: 50px;display: inline-block;background-color: red;border-radius: 20%;}/* 实心圆 */.xmbook_red_point_3 {width: 50px;height: 50px;/* position: relative; *//* bottom: 2px; *//* left: 4px; */display: inline-block;/* background: url(/zh_CN/htmledition/images/icon_xmbook_red_point513f4c.png); */background-color: red;border-radius: 50%;}/* 空心圆 */.xmbook_red_point_4 {width: 50px;height: 50px;display: inline-block;/* background-color: red; */border-radius: 50%;border: 2px solid;border-color: red;}/* 圈中带字 */.xmbook_red_point_5 {width: 50px;height: 50px;display: inline-block;/* background-color: red; */border-radius: 50%;border: 2px solid;border-color: red;/* 设置圈中字体大小等 */font: 14px Arial, sans-serif;/* 下面是调整圈中字体位置的 */display: flex;justify-content: center;align-items: center;/* text-align: center; */}</style>
    </head>
    <body><div class="xmbook_red_point_1"></div><div class="xmbook_red_point_2"></div><div><i class="xmbook_red_point_3"></i></div><div><i class="xmbook_red_point_4"></i></div><!-- 圈中带字 --><div><i class="xmbook_red_point_5">10</i></div><div class="xmbook_red_point_5">12</div></body>
    </html>
    

2. 动态圆

2.1 一个动态圆

2.1.1 让圆渐变

  • 效果如下:
    在这里插入图片描述

  • 实现代码如下:

    <!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>/* 空心圆 */.xmbook_red_point_4 {width: 100px;height: 100px;/* display: inline-block; *//* background-color: red; */border-radius: 50%;/* border: 2px solid; *//* border-color: red; */position: absolute;top: 150px;left: 150px;/* identifier 3s 控制动的频率 linear infinite 让动画不断渐变不要停transform-origin 控制运动轨迹*/animation: identifier 3s infinite linear;transform-origin: 150px 150px ;}@keyframes identifier{   /*用“0%-100%” 或者 “from-to” 均可以*/  from{transform: rotate(360deg) scale(1);border: 10px solid rgb(143, 182, 222);}to{transform: rotate(360deg) scale(1);border: 10px solid rgb(2, 36, 70);}}</style>
    </head>
    <body><div class="xmbook_red_point_4"></div></body>
    </html>
    

2.1.2 圆渐变8秒后消失

  • 代码实现如下:

    <!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>/* 空心圆 */.xmbook_red_point_4 {width: 100px;height: 100px;/* background-color: red; */border-radius: 50%;/* border-color: red; */position: absolute;top: 150px;left: 150px;/* identifier 3s 控制动的频率 linear infinite 让动画不断渐变不要停transform-origin 控制运动轨迹*/animation: identifier 8s infinite linear;/* transform-origin: 150px 150px ; */}@keyframes identifier {100% {/* transform: rotate(360deg) scale(1); */border: 10px solid rgb(6, 68, 130);}}</style>
    </head>
    <body><div class="xmbook_red_point_4"></div></body>
    </html>
    

2.1.3 转动的圆(单个圆)

  • 实现效果如下:

css实现圆转动(单个圆)

  • 实现代码如下:

    <!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>/* 空心圆 */.xmbook_red_point_4 {width: 100px;height: 100px;background-color: red;border-radius: 50%;/* border-color: rgb(0, 98, 255); */position: absolute;top: 150px;left: 150px;/* identifier 3s 控制动的频率 linear infinite 让动画不断渐变不要停transform-origin 控制运动轨迹*/animation: identifier 5s infinite linear;transform-origin: 150px 150px ;}@keyframes identifier {100% {transform: rotate(360deg) scale(1);/* border: 10px solid rgb(6, 68, 130); */}}</style>
    </head>
    <body><div class="xmbook_red_point_4"></div></body>
    </html>
    

2.2 多个动态圆

  • 实现效果如下:

css实现多个运动的圆

  • 实现代码如下:
    <!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>/* 空心圆 */.xmbook_red_point_4 {width: 100px;height: 100px;background-color: rgb(9, 163, 30);border-radius: 50%;/* border-color: rgb(0, 98, 255); */position: absolute;top: 150px;left: 150px;/* identifier 3s 控制动的频率 linear infinite 让动画不断渐变不要停transform-origin 控制运动轨迹*/animation: identifier 5s infinite linear;transform-origin: 100px 100px ;}/* 如果让三圆重叠,把下面的 120px 调成 100px 或更小即可 */.xmbook_red_point_4:nth-child(1) {animation: identifier 9s infinite linear;transform-origin: 120px 120px;}.xmbook_red_point_4:nth-child(2) {animation: identifier 9s infinite -3s linear;transform-origin: 120px 120px;}.xmbook_red_point_4:nth-child(3) {animation: identifier 9s infinite -6s linear;transform-origin: 120px 120px;}@keyframes identifier {0% {transform: rotate(0deg) scale(1);border: 10px solid rgb(4, 212, 195);}30% {transform: rotate(120deg) scale(1);border: 10px solid rgb(33, 4, 147);}100% {transform: rotate(360deg) scale(1);border: 10px solid rgb(132, 7, 9);}}</style>
    </head>
    <body><div class="xmbook_red_point_4"></div><div class="xmbook_red_point_4"></div><div class="xmbook_red_point_4"></div>
    </body>
    </html>
    
http://www.lryc.cn/news/218966.html

相关文章:

  • K8S知识点(一)
  • 人工智能师求职面试笔试题及答案汇总
  • 【Windows-软件-FFmpeg】(01)通过CMD运行FFmpeg进行操作,快速上手
  • Spring Data Redis + RabbitMQ - 基于 string 实现缓存、计数功能(同步数据)
  • Facebook Developer 的 HashCode
  • 下载使用 ant design Pro 中遇到的一些问题
  • 「Java开发指南」如何用MyEclipse搭建Spring MVC应用程序?(一)
  • [动态规划] (七) 路径问题:LCR 166.剑指offer 47. 珠宝的最高价值
  • Mysql进阶-SQL优化篇
  • VueI18n中英文切换 vue2.0
  • VUE组件间通信的七种方式
  • 问chatgpt最近生活的困难
  • Flink源码解析八之任务调度和负载均衡
  • 4.3 传送门
  • NLP之Bert介绍和简单示例
  • 【Windows】Google和火狐浏览器禁用更新的操作方式
  • 关于编程不得不说的事
  • 2.4G合封芯片 XL2422,集成M0核MCU,高性能 低功耗
  • 【QT基础入门 控件篇】QLineEdit 基础、高级和样式表使用详解
  • 网络安全(网络安全)小白自学
  • dupeGuru 清理微信重复文件
  • 华为RS设备状态及接口配置命令
  • 单链表的应用(2)
  • 【Boost | C++】使用Boost库创建文件夹
  • 月报总结|Moonbeam 10月份大事一览
  • Latex安装记录
  • JavaEE-博客系统2(功能设计)
  • 2023年【高处安装、维护、拆除】免费试题及高处安装、维护、拆除找解析
  • antv/g6之交互模式mode
  • 基于8086电压表系统仿真系统设计