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>
  • 相关阅读:
    多进程编程
    Python 的下载安装
    cnBlogs windows LIves Writes 安装
    第四章网页文字编排设计
    第三章网页图形图像设计
    第二章网页创意设计思维和方法
    1.3-1.4网页设计的定位和流程
    1.2网页设计的构成要素和特性
    网页编辑常用快捷方式+学习技巧+网站开发流程
    css选择器2——伪类选择器
  • 原文地址:https://www.cnblogs.com/aqxss/p/6053009.html
Copyright © 2011-2022 走看看