css-方形组件圆形阴影和动画

3 篇文章 0 订阅

css-方形组件圆形阴影和动画 目录

文章目录


前言

  • CSS特效
  • 思路:1个div包裹4个,最外层作为阴影来源,内部4个作为补齐补板。
  • 主要用到以下:
    • border-radius
    • box-shadow
    • @keyframe, animation
    • z-index
    • transition
    • position, top, left

效果

在这里插入图片描述

代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Border Radius</title>
    <style>
        body{
            background-color: pink;
        }

        #box1 {
            width: 100px;
            height: 100px;
            background: #ffffff;
            position: relative;
            margin: 30% auto;
            border-radius: 50%;
            box-shadow: 15px 15px 17px 17px rgba(0,0,0,0.2);
			transition: 2s;
            animation-name: test;
            animation-direction: reverse;
            animation-duration: 2s;
            animation-timing-function: linear;
            animation-iteration-count: infinite;
            animation-fill-mode: forwards;
            z-index: 999;
        }

        #box2 {
            width: 30px;
            height: 100px;
            border-radius: 50%;
            background-color: #ffffff;
            position: absolute;
            top: 0;
            left: 80px;
            z-index: 1;
        }

        #box3 {
            width: 30px;
            height: 100px;
            border-radius: 50%;
            background-color: #ffffff;
            position: absolute;
            top: 0;
            right: 80px;
            z-index: 1;
        }

        #box4 {
            width: 100px;
            height: 30px;
            border-radius: 50%;
            background-color: #ffffff;
            position: absolute;
            top: 80px;
            z-index: 1;
        }

        #box5 {
            width: 100px;
            height: 30px;
            border-radius: 50%;
            background-color: #ffffff;
            position: absolute;
            bottom: 80px;
            z-index: 1;
        }

        @keyframes test {
            from {
                background-color: aqua;
                opacity: 0.5;
            }

            to {
                background-color: purple;
                opacity: 1;
            }
        }
    </style>
</head>
<body>
<div id="box1">
    <div id="box2"></div>
    <div id="box3"></div>
    <div id="box4"></div>
    <div id="box5"></div>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值