zoukankan      html  css  js  c++  java
  • 导航带标记效果同时附带锚点效果

    学习过程中遇到一个复合的问题,就是如何把锚点和导航标记效果复合到一起去,如下:

    代码部分:

    <div id="hdaohang"></div>
    <div id="hdaohang1">
        <div name="div" class="hdhdiv" onclick="cx(this)">GTR车型</div>
        <div name="div" class="hdhdiv" onclick="gs(this)">GTR公司</div>
        <div name="div" class="hdhdiv" onclick="ls(this)">GTR历史</div>
        <div name="div" class="hdhdiv" onclick="jj(this)">GTR简介</div>
    </div>

    CSS部分:

    #hdaohang{ width:1350px; height:40px; margin-left:20px; background-color:gray; z-index:10; position:fixed; opacity:0.7}
    #hdaohang1{ width:1350px; height:40px; margin-left:18px;  z-index:10; position:fixed; }
    .hdhdiv{ width:315px; height:40px; float:left; text-align:center; vertical-align:middle; line-height:40px; color:#FFF; transition:0.7s; border-radius:5px; transition:1s; float:right}
    .hdhdiv:hover{ cursor:pointer; background-color:#999;}

    JS部分:

    function jj(dd)
    {
        window.scrollTo(0,520);
        resetNav();
        dd.style.backgroundColor="#000000";
    }
    function ls(dd)
    {
        window.scrollTo(0,980);
        resetNav();
        dd.style.backgroundColor="#000000";
    }
    function gs(dd)
    {
        window.scrollTo(0,3425);
        resetNav();
        dd.style.backgroundColor="#000000";
        
    }
    function cx(dd)
    {
        window.scrollTo(0,3900);
        resetNav();
        dd.style.backgroundColor="#000000";
    }
    
    function resetNav()
    {
        //移除style属性
        var divs = document.getElementsByClassName("hdhdiv");
        for(var i=0;i<divs.length;i++)
        {
            divs[i].removeAttribute("style");
        }
    }

    特效如下:

  • 相关阅读:
    mysql 表分区
    mysql 存储过程和函数
    mysql 主从复制
    nginx 生产中配置记录
    harbor资源管理垃圾回收
    harbor部署
    docker使用nfs 做跨主机存储
    基于Gluster分布式实现docker存储卷
    docker 部署elasticsearch集群
    记一次iptables配置(REJECT --reject-with icmp-host-prohibited)
  • 原文地址:https://www.cnblogs.com/claricre/p/6144626.html
Copyright © 2011-2022 走看看