css实现一个摇动的铃铛提醒动画效果代码

代码语言:html

所属分类:动画

代码描述:css实现一个摇动的铃铛提醒动画效果代码

代码标签: 铃铛 摇动 提醒 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">


    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">

    <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&amp;display=swap'>

    <style>
        * {
        	border: 0;
        	box-sizing: border-box;
        	margin: 0;
        	padding: 0;
        }
        :root {
        	--hue: 223;
        	--bg: hsl(var(--hue),10%,90%);
        	--fg: hsl(var(--hue),10%,10%);
        	font-size: calc(40px + (60 - 40) * (100vw - 320px) / (1280 - 320));
        }
        body, button {
        	color: var(--fg);
        	font: 1em/1.5 "DM Sans", sans-serif;	
        }
        body {
        	background: var(--bg);
        	height: 100vh;
        	display: grid;
        	place-items: center;
        }
        .notifications {
        	background: transparent;
        	box-shadow: 0 0 0 0.1em transparent;
        	filter: brightness(1) grayscale(1);
        	position: relative;
        	width: 1.5em;
        	height: 1.5em;
        	transition: filter 0.15s 0.3s linear;
        	-webkit-appearance: none;
        	appearance: none;
        	-webkit-tap-highlight-color: transparent;
        }
        .notifications:focus {
        	outline: none;
        }
        .notifications:before,
        .notifications:after,
        .notifications__badge,
        .notifications__waves,
        .notifications__sr {
        	position: absolute;
        }
        .notifications:before,
        .notifications:after {
        	content: "";
        	display: block;
        }
        .notifications:before {
        	background: radial-gradient(0.4em 0.4em at 50% 1.1em,hsl(38,90%,55%) 47%,hsla(38,90%,55%,0) 50%);
        	top: 0.2em;
        	left: calc(50% - 0.2em);
        	width: 0.4em;
        	height: 1.3em;
        	transform-origin: 50% 0.2em;
        }
        .notifications:after {
        	background:
        		/* rim  */
        		radial-gradient(0.4em 0.2em at 0.2em 1.2em,hsl(45,90%,55%) 46%,hsla(45,90%,55%,0) 50%),
        		linear-gradient(hsl(45,90%,55%),hsl(45,90%,55%)) 0.2em 1.1em / 1.1em 0.2em no-repeat,
        		radial-gradient(0.4em 0.2em at 1.3em 1.2em,hsl(45,90%,55%) 46%,hsla(45,90%,55%,0) 50%),
        		/* middle  */
        		radial-gradient(1.2em 1.2em at 50% 0.75em,hsl(38,90%,55%) 49%,hsla(38,90%,55%,0) 50%) 0 0 / 100% 75% no-repeat,
        		linear-gradient(hsl(38,90%,55%),hsl(38,90%,55%)) 0.15em 0.75em / 1.2em 0.4em no-repeat,
        		/* top */
        		radial-gradient(0.3em 0.3em at 50% 0.15em,hsl(45,90%,55%) 48%,hsla(45,90%,55%,0) 50%);
        	top: 0;
        	left: 0;
        	width: 100%;
        	height: 100%;
        	transform-origin: 50% 0.15em;
        }
        .notifications__badge {
        	background: hsl(3,90%,55%);
        	border-radius: 0.375rem;
        	color: hsl(0,0%,100%);
        	font-size: 0.5em;
        	font-weight: bold;
        	padding: 0 0.125rem;
        	top: -0.125rem;
        	right: -0.125rem;
        	min-width: 0.75rem;
        	height: 0.75rem;
        	text-align: center;
        	transition: transform 0.3s 0.15s ease-out;
        	z-index: 1;
        }
        .notifications__badge:empty {
        	transform: scale(0);
        	transition-delay: 0s;
        }
        .notifications__waves,
        .notifications--active:before,
        .notifications--active:after {
        	animation-duration: 2s;
        	animation-timing-function: linear;
        	animation-iteration-count: infinite;
        }
        .notifications__waves {
        	animation-delay: 0.6s;
        	border-top: 0.1em solid transparent;
        	border-right: 0.1em solid hsla(var(--hue),10%,50%);
        	border-bottom: 0.1em solid transparent;
        	border-left: 0.1em solid hsla(var(--hue),10%,50%);
        	border-radius: 50%;
        	top: -50%;
        	left: -50%;
        	opacity: 0;
        	pointer-events: none;
        	width: 200%;
        	height: 200%;
        	transform: scale(0.3);
        }
        .notifications__waves:nth-child(2) { animation-delay: 0.75s; }
        .notifications__waves:nth-child(3) { animation-delay: 0.9s; }
        .notifications__waves:nth-child(4) { animation-delay: 1.05s; }
        
        .notifications--active {
        	filter: brightness(1) grayscale(0);
        	transition-delay: 0s;
        }
        .........完整代码请登录后点击上方下载按钮下载查看

网友评论0