弹性伸缩展开工具菜单栏 js

css 复制代码
<style>
 *{
            margin:0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
            background: #222;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-wrap: wrap;
            min-height: 100vh;
        }
        .button{
            color: #fff;
            text-align: center;
            width:70px;
            height:70px;
            border-radius: 50%;
            background: #4c3ab0;
            position: relative;
        }
        .button::after{
            content: "+";
            position: absolute;
            inset:-6.5px;/*设置定位布局,上下左右各相距6.5px*/
            font-size: 3.5em;
        }
        .button.active{
            transform: rotate(45deg);
        }
        .icons.open{
            width:80%;
        }
        .icons{
            width:0;
            height:65px;
            list-style: none;
            padding:16px 10px 10px 50px;
            background: #ffffff;
            box-shadow: 1px 1px 1px #dcdcdc;
            border-radius: 2em;
            display: flex;
            justify-content: space-evenly;
            align-items: center;
        }
        .icons li  img{
            width:36px;

        }
        .icons li:nth-child(1){
            margin-left: 50px;
        }
        .icons li{
            width:80px;
           
        }
        .button{
            left:50%;
            margin-left: -35px;
            z-index:1;
        }
        .button,.icons{
            transition: all 1s cubic-bezier(0.85,-.57,0.37,2.99);
        }
        .icons{
            margin:-68px 0 0 44%;
            overflow: hidden;
            opacity: 0;
        }
        .button.active{
            left:60px;
            
        }
        .icons.open{
            margin:-68px 0 0 6%;
            opacity: 1;
        }
</style>
html 复制代码
<body>
    <div class="toolbar">
        <div class="button"></div>
        <ul class="icons">
            <li><img src="/iconBox/mine.png" alt=""></li>
            <li><img src="/iconBox/mine.png" alt=""></li>
            <li><img src="/iconBox/mine.png" alt=""></li>
            <li><img src="/iconBox/mine.png" alt=""></li>
            <li><img src="/iconBox/mine.png" alt=""></li>
        </ul>
    </div>
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js">
    </script>
    <script>
        $('.button').click(function(){
            $('.button').toggleClass('active')
            $('.icons').toggleClass('open')
        })
    </script>
</body>
相关推荐
「、皓子~39 分钟前
AI创作系列(2):UniApp跨端开发实战 - 海狸IM移动端完全由AI编写
开发语言·人工智能·uni-app·开源·vue·开源软件·ai编程
南無忘码至尊1 小时前
Unity C# 入门基础知识点整理与实战技巧
开发语言·c#
江梦寻1 小时前
软件工程教学评价
开发语言·后端·macos·架构·github·软件工程
iCxhust1 小时前
汇编字符串比较函数
c语言·开发语言·汇编·单片机·嵌入式硬件
戒不掉的伤怀1 小时前
react实现axios 的简单封装
javascript·react.js·ecmascript
夏梦春蝉2 小时前
ES6从入门到精通:变量
前端·javascript·es6
步行cgn2 小时前
ES6 核心语法手册
前端·javascript·es6
XMYX-02 小时前
Python 实现一个带进度条的 URL 批量下载工具(含 GUI 界面)
开发语言·python
sorryhc2 小时前
React SSR同构渲染方案是什么?
前端·javascript·next.js
小公主2 小时前
别再乱用异步了!一文搞懂 Promise 和 async/await 的执行顺序与最佳实践
javascript