弹性伸缩展开工具菜单栏 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>
相关推荐
meilindehuzi_a3 小时前
从零理解并实现 RAG:用 LangChain.js 构建语义检索问答系统
开发语言·javascript·langchain
风流 少年4 小时前
Julia
开发语言·julia
江畔柳前堤4 小时前
GO01-Go 语言与主流编程语言深度对比
开发语言·人工智能·后端·微服务·云原生·golang·go
:-)5 小时前
算法-归并排序
java·开发语言·数据结构·算法·排序算法
鱼樱前端5 小时前
别再自己拼凑了!这款 Vue 3.5+ 严肃产品级组件库,把 AI 对话、工作流和复杂数据全包了!
javascript·vue.js·github
Listen·Rain5 小时前
Vue3:setup详解
前端·javascript·vue.js
GIS阵地5 小时前
QgsRasterDataProvider 完整详解(QGIS 3.40.13 C++)
开发语言·c++·qt·开源软件·qgis
yaoxin5211236 小时前
462. Java 反射 - 获取声明类与封闭类
java·开发语言·python
kyriewen6 小时前
面试官让我优化一个卡死的表格,我打开 Claude 五秒重写,他放下咖啡问我要不要来当组长
前端·javascript·面试
阿里嘎多学长7 小时前
2026-07-14 GitHub 热点项目精选
开发语言·程序员·github·代码托管