zoukankan      html  css  js  c++  java
  • 菜单 字体鼠标操控的效果

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
    #caidan{
        500px; height:35px; border:1px solid #60f;
        
        }
    .xiang{
        100px;
        height:35px;
        text-align:center;
        line-height:35px;
        vertical-align:middle;
        float:left;
        
        }
    </style>
    </head>
    
    <body>
    
    <div id="caidan">
        <div class="xiang" onMouseOver="huan(this)">首页</div>
        <div class="xiang" onMouseOver="huan(this)">产品中心</div>
        <div class="xiang" onMouseOver="huan(this)">服务中心</div>
        <div class="xiang" onMouseOver="huan(this)">联系我们</div>
    
    
    </div>
    
    
    </body>
    <script type="text/javascript">
    /*-------------------以后常用-----下面的------------------------*/
    function huan(a)
    {    
        //将所有的項回复原样式
        var d=document.getElementsByClassName("xiang");
        for(var i=0;i<d.length;i++)
        {
            d[i].style.backgroundColor="white";
            d[i].style.color="black";
        }
        
        //换该元素的样式   鼠标移上去换色
        a.style.backgroundColor="red";
        a.style.color ="white";
        //
    }
    <!-------------------第二种方式也可以实现效果-------------------------------------->
    /*<div id="caidan">
        <div class="xiang" onMouseOver="huan(this)" onMouseOut="huifu(this)">首页</div>
        <div class="xiang" onMouseOver="huan(this)" onMouseOut="huifu(this)">产品中心</div>
        <div class="xiang" onMouseOver="huan(this)" onMouseOut="huifu(this)">服务中心</div>
        <div class="xiang" onMouseOver="huan(this)" onMouseOut="huifu(this)">联系我们</div>
    
    
    </div>
    function huifu(a)
    {
        a.style.backgroundColor="white";//文字是黑色
        a.style.color="white";
    }*/
    </script>
    
    </html>
  • 相关阅读:
    阿里妈妈MaxCompute架构演进_-_AON(MPI)集群
    阿里云ECS部署Grafana接入zabbix
    ECS实例RAM角色实践
    上海云栖—人工智能-视觉计算专场预热
    阿里云论坛版主制作最新教程汇总贴
    移动相关的css
    GULP入门(一)
    mongodb+nodejs 增删查的demo
    nodejs+express 初学(三)
    nodejs+express 初学(二)
  • 原文地址:https://www.cnblogs.com/aqxss/p/6053009.html
Copyright © 2011-2022 走看看