css之呼吸灯效果

1、首先脑补一个知识点,我们在代码中经常看到-webkit或-moz,那这些有什么作用了,看下代码就知道了:

-webkit-border-radius: 2px;       /*Webkit:谷歌支持:圆角*/
-moz-border-radius: 2px;          /*Mozilla:火狐支持:圆角*/
-ms-border-radius: 2px;           /*Microsoft:IE9支持:圆角*/
-o-border-radius: 2px;            /*Opera支持:圆角*/
border-radius: 2px;               /*圆角*/

2、好了,呼吸灯的原理就是修改标签的不透明度,主要利用到css3的animation动画

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <title>呼吸灯</title>
    <style type="text/css">
    /* css代码 */
    </style>
</head>
<body>
    <div class="breath_light" title="呼吸线"></div>
</body>
</html>

3、css代码是这样的:

.breath_light {
        width: 50px;                                    /* 宽度 */
        height: 4px;                                    /* 高度 */
        opacity: 0.1;                                   /* 不透明度 */
        overflow: hidden;                               /* 溢出隐藏 */
        background: #99dd33;                            /* 背景色 */
        margin: 25% auto;                               /* 外边距 */
  
        /* IE10、Firefox and Opera,IE9以及更早的版本不支持 */
        animation-name: breath;                         /* 动画名称 */
        animation-duration: 3s;                         /* 动画时长3秒 */
        animation-timing-function: ease-in-out;         /* 动画速度曲线:以低速开始和结束 */
        animation-iteration-count: infinite;            /* 播放次数:无限 */
 
       /* Safari and Chrome */
        -webkit-animation-name: breath;                 /* 动画名称 */
        -webkit-animation-duration: 3s;                 /* 动画时长3秒 */
        -webkit-animation-timing-function: ease-in-out; /* 动画速度曲线:以低速开始和结束 */
        -webkit-animation-iteration-count: infinite;    /* 播放次数:无限 */
    }
 
    @keyframes breath {
        from { opacity: 0.1; }                          /* 动画开始时的不透明度 */
        50%  { opacity:   1; }                          /* 动画50% 时的不透明度 */
        to   { opacity: 0.1; }                          /* 动画结束时的不透明度 */    
    }
 
    @-webkit-keyframes breath {
        from { opacity: 0.1; }                          /* 动画开始时的不透明度 */
        50%  { opacity:   1; }                          /* 动画50% 时的不透明度 */
        to   { opacity: 0.1; }                          /* 动画结束时的不透明度 */
    }

css之呼吸灯效果

时间: 2024-08-28 22:39:46

css之呼吸灯效果的相关文章

CSS 实现按钮及线呼吸灯效果

1. [代码]style    view sourceprint?01<style>02            body{03                font-family:'Segoe UI Light','Segoe UI',Arial,'微软雅黑',sans-serif;04                font-size: 20px;05                color:#333333;06 07            }08            .breath

2416 呼吸灯 效果

#include <stdint.h> #include <stdbool.h> #include <raw_api.h> #include <lib_string.h> #include <2416_reg.h> #include <pwm.h> #include <irq.h> #include <timer.h> #include <pwm.h> #include <rsh.h>

CSS动画总结与呼吸灯效果

首先,先介绍一下主要用到的css属性:animation,text-shadow. text-shadow就不再介绍了,上一篇已经详细介绍了用法.这里先介绍一下animation属性. 1.animation animation是css3的属性,主要有以下几项: 属性 描述   @keyframes 规定动画.   animation 所有动画属性的简写属性,除了 animation-play-state 属性.   animation-name 规定 @keyframes 动画的名称.   a

好玩的WPF第二弹:电子表字体显示时间+多彩呼吸灯特效button

我们先来看看Quartz MS字体动态显示系统时间的效果,难度相较于上一篇也要简单很多. 首先是定义一个TextBlock例如以下. <Grid> <TextBlock Name="tBlockTime" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="68" Foreground="Green"/>

(原创)用Verilog实现一个参数化的呼吸灯(Verilog,CPLD/FPGA)

1.Abstract     观察到一个有趣的现象,每当把Apple笔记本合上的时候,那个白色的呼吸灯就会反复地由暗渐明,然后又由明渐暗,乍一看就像Apple笔记本在打盹休息一样,十分可爱!于是突发奇想,要不用Verilog也写一个吧,资源也不需要太多,一个LED灯就可以了.为了使用方便,可以把它做成参数化的,可以根据时常进行参数调节:深睡.浅睡跟清醒的时候呼吸频率似乎是不一样的-     下面就来分析和实践一下. 2.Content   2.1 理论分析     根据上述描述的现象,仔细分析一

STM32呼吸灯

使用STM32开发板和mbed平台实现的一个呼吸灯.材料,LED灯,电阻,STM32开发板. 先上一张效果图. 背景: 我们之前设置GPIO口使用了DigitalOut,数字信号输出.只能是GPIO口为0或1两个值.在LED上体现的即是灭和亮.然而现实世界大量的信号都是模拟信号,如温度.声音.加速度等.百度上:“模拟信号是指信息参数在给定范围内表现为连续的信号. 或在一段连续的时间间隔内,其代表信息的特征量可以在任意瞬间呈现为任意数值的信号.” 理论知识(可以跳过): 模拟信号即可以简单理解为,

基于PWM的呼吸灯设计(Verilog版)

module Breath_Led(clk,rst,led); input clk,rst; output reg led; reg[19:0] count; reg[19:0] duty_cycle; always @(posedge clk) begin if(!rst) begin led<=1'b0; count<=1'b0; end else begin if(count<20'd999_999) begin count<=count+1'b1; if(count<

HTML和CSS中的居中效果(1)

HTML和CSS中的居中效果 单行上下左右居中 Html: <div class="container"></div> CSS: .container{ width: 600px; height: 300px; text-align: center; line-height: 300px; border: 1px solid green; } 固定高宽上下左右居中 Html: <div class="container"><

css冻结列的效果

<!DOCTYPE html><html lang="zh-cn"><head><meta charset="utf-8" /><title>css冻结列的效果</title><!-- 1.div里面放table或者其它容器,当子容器的宽度大于父容器时,父容器就会出现滚动条.2.头部固定不动的列让它脱离文档流(position:fixed|absolute),然后给table一个margi