固定底部圆形环绕导航

作者: kerush | 来源:发表于2017-05-16 11:04 被阅读61次
前端入坑纪 17

生命不息,更新不止!

素素的圆形环绕导航

OK,first things first!项目链接

HTML 结构
    <div id="Btns" class="navWrp impt">

        <a href="javascript:;">导航0</a>

        <a href="javascript:;">导航1</a>

        <a href="javascript:;">导航2</a>

        <a href="javascript:;">导航3</a>

        <a href="javascript:;">导航4</a>

        <a href="javascript:;">导航5</a>

    </div>
    <nav>
        <a id="mainBtn" class="navBtn" href="javascript:;">导航</a>
    </nav>

都是些必要的元素,没啥特殊

CSS 结构
        * {
            margin: 0;
            padding: 0
        }
        
        a {
            color: #333;
            text-decoration: none;
        }
        
        html,
        body {
            font-family: "Microsoft YaHei", Verdana, Geneva, Tahoma, sans-serif;
            height: 100%;
            background: #fefefe;
            text-align: center;
        }
        
        .clear::after {
            content: "";
            display: table;
            clear: both
        }
        
        ul,
        li {
            list-style: none
        }
        
        .navWrp {
            display: none;
            position: fixed;
            z-index: 2;
            left: 50%;
            bottom: -20px;
            height: 160px;
            width: 160px;
            margin-left: -80px;
            /*border: 1px solid #ccc;*/
            border-radius: 50%;
        }
        
        .navWrp a {
            display: block;
            position: absolute;
            height: 40px;
            width: 40px;
            line-height: 40px;
            text-align: center;
            border-radius: 50%;
            font-size: 12px;
            background-color: skyblue;
            color: #fff;
            transition: all 200ms ease;
            z-index: 9
        }
        /*当隐藏时重置所有a的定位*/
        
        .navWrp.impt a {
            top: 80px!important;
            left: 60px!important;
        }
        /*所有a显示时a的各自定位*/
        
        .navWrp a:nth-child(1) {
            top: 60px;
            left: -20px
        }
        
        .navWrp a:nth-child(2) {
            top: 5px;
            left: 5px
        }
        
        .navWrp a:nth-child(3) {
            top: -20px;
            left: 60px
        }
        
        .navWrp a:nth-child(4) {
            top: -20px;
            left: 60px
        }
        
        .navWrp a:nth-child(5) {
            top: 5px;
            left: 115px
        }
        
        .navWrp a:nth-child(6) {
            top: 60px;
            left: 140px
        }
        
        nav {
            box-shadow: 0 0 1px #ccc;
            position: fixed;
            z-index: 3;
            width: 100%;
            left: 0;
            bottom: 0;
            height: 40px;
            line-height: 40px;
            text-align: center;
        }
        
        .navBtn {
            position: relative;
            /*相对自己往上20px*/
            top: -20px;
            display: inline-block;
            width: 40px;
            font-size: 12px;
            color: #fff;
            border-radius: 50%;
            background-color: skyblue
        }

这个难点就是每个a的定位值,一般算下就可以了,或者直接用手动调,就是会费时点

JS 结构
        var oMbtn = document.getElementById("mainBtn"),
            obtns = document.getElementById("Btns"),
            obtnsA = obtns.getElementsByTagName("a");
        oMbtn.setAttribute("show", "off");
        oMbtn.onclick = function() {
            if (oMbtn.getAttribute("show") == "off") {
                obtns.style.display = "block";
                // obtns显示后,再开始动画
                setTimeout(function() {
                    obtns.className = "navWrp";
                }, 30);

                oMbtn.setAttribute("show", "on");
            } else {
                obtns.className = "navWrp impt";
                // 动画完成后,隐藏obtns
                setTimeout(function() {
                    obtns.style.display = "none";
                }, 300);
                oMbtn.setAttribute("show", "off");
            }

        }

这里用show属性来判定状态,然后不同状态,不同的点击效果

环绕的a点击完,隐藏的js没写,有兴趣的,可以自己mark。

相关文章

  • 固定底部圆形环绕导航

    前端入坑纪 17 生命不息,更新不止! OK,first things first!项目链接 HTML 结构 都是...

  • 大屏动效设计

    背景动效: 背景数字流变成二进制码 主导航光旋特效微微闪烁 主导航 底部椭圆形光晕,放大效果闪烁 ————————...

  • BottomNavigationView的属性设置

    底部导航栏 底部导航栏的使用比较常见,目前常用的APP几乎都是使用底部导航栏将内容分类。底部导航栏的实现也比较简单...

  • CSS经典布局之高度布局

    【解决需求】解决高度布局中部分高度固定,部分高度自适应的问题 【实际情况中的应用】网站顶部导航栏(以及底部栏)固定...

  • Android使用底部导航2018-08-16

    Android使用底部导航 Android底部导航停留在屏幕底部,提供应用中顶级视图之间的导航。这是在具有向后兼容...

  • 有一种看似多余的导航你知道吗?

    很多网站在页面底部也有导航,这种底部导航看似有些多余。但是他们的作用不比主导航差。 底部导航的作用和做法有如下几种...

  • 为什么底部导航被人忽视

    很多网站在页面底部也有导航,这种底部导航看似有些多余。但是他们的作用不比主导航差。 底部导航的作用和做法有如下几种...

  • 底部导航思路

    底部导航是每个 app 必备的,有的 app 底部导航做的很精美,很有诱人,于是我去特意看看底部导航都有那些玩法 ...

  • 底部固定

    使用calc()方法 HTML部分 css部分 查看链接

  • 不规则的文字环绕问题

    常见的文字环绕效果: 1.圆形环绕效果 css代码: 2.椭圆形文字环绕 css代码: 3.三角形文字环绕

网友评论

    本文标题:固定底部圆形环绕导航

    本文链接:https://www.haomeiwen.com/subject/vunkxxtx.html