JS来操作hover
hover我们可以用css的方式写,当然,也可以用js的方式写
<html>
<head>
<title>js的下拉菜单效果</title>
<style type="text/css">
*{
padding:0px;
margin:0px;
}
ul li{
list-style: none;
}
a{
text-decoration: none
}
.header{
height: 45px;
background-color:#FBFBFB;
border-bottom: 1px solid #C7C7C7;
}
.header-center{
width: 1000px;
height: 100%;
margin: 0 auto;
position: relative;
}
.header-mobile{
width: 130px;
position: absolute;
top:0;
right: 0;
text-align: center;
}
/* .header-mobile:hover .header-mobile-list{
display: block;
}*/
.header-mobile a{
display: block;
height: 45px;
line-height: 45px;
color:#000000;
}
.header-mobile-list{
display: none;
background:url(bg.png) no-repeat;
background-position: 20px 18px; }
.header-mobile-list li{
height: 45px;
border-bottom: 1px dashed gray;
font-family: '微软雅黑';
line-height: 50px;
padding-left: 35px;
padding-top: 5px;
}
</style>
</head>
<body>
<header class="header">
<div class="header-center">
<div class="header-mobile" id="headerMobile">
<a href="">移动客户端</a>
<ul class="header-mobile-list" id="mobileList">
<li>新浪微博</li>
<li>新浪新闻</li>
<li>新浪体育</li>
<li>新浪娱乐</li>
<li>新浪财经</li>
<li>天气通</li>
</ul>
</div>
</div>
</header>
</body>
<script type="text/javascript">
//封装选择ID
window.onload=function(){
function $(id){
return document.getElementById(id);
}
//鼠标进
$("headerMobile").onmouseover=function(){
// this.style.display="none";
$("mobileList").style.display="block"
//给当钱的添加样式
this.style.boxShadow=" 0 2px 2px gray"
}
//鼠标出
$("headerMobile").onmouseout=function(){
$("mobileList").style.display="none"
this.style.boxShadow='none'
} }
</script>
</html>
JS来操作hover的更多相关文章
- js简单操作Cookie
贴一段js简单操作Cookie的代码: //获取指定名称的cookie的值 function getCookie(objName) { var arrStr = document.cookie.spl ...
- 使用HTML5的JS选择器操作页面中的元素
文件命名为:querySelector.html,可在Chrome浏览器中预览效果. 1 <!DOCTYPE html> 2 <html lang="en"> ...
- node.js高效操作mongodb
node.js高效操作mongodb Mongoose库简而言之就是在node环境中操作MongoDB数据库的一种便捷的封装,一种对象模型工具,类似ORM,Mongoose将数据库中的数据转换为Jav ...
- js字符串操作
javascript中字符串常用操作总结.JS字符串操作大全 String对象属性 (1) length属性 length算是字符串中非常常用的一个属性了,它的功能是获取字符串的长度.当然需要注意的是 ...
- Node.js之操作文件系统(一)
Node.js之操作文件系统(一) 1. 同步方法与异步方法 在Node.js中,使用fs模块来实现所有有关文件及目录的创建.写入及删除操作.,在fs模块中,所有对文件及目录的操作都可以使用同步与异步 ...
- Node.js之操作文件系统(二)
Node.js之操作文件系统(二) 1.创建与读取目录 1.1 创建目录 在fs模块中,可以使用mkdir方法创建目录,该方法的使用方法如下: fs.mkdir(path,[mode],callbca ...
- js数组操作-添加,删除
js 数组操作常用方法. push():在数组后面加入元素,并返回数组的长度 unshift():在数组前面加入元素,并返回数组的长度 pop()删除最后一个元素 shift()删除第一个元素 var ...
- 页面循环绑定(变量污染问题),js面向对象编程(对象属性增删改查),js字符串操作,js数组操作
页面循环绑定(变量污染问题) var lis = document.querySelectorAll(".ul li") for ( var i = 0 ; i < lis. ...
- js数组操作-最佳图解
js数组操作-最佳图解
随机推荐
- github student pack中的digital ocean可以使用银联卡支付
申请了 github student pack却因为一直没有visita信用卡,而无法使用digital ocean的 $50,一直到今天,用中国银行借记卡成功支付. 方法是: (1)注册paypal ...
- 【leetcode】Best Time to Buy and Sell Stock II
Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a ...
- chrome浏览器关闭标签页面
chrome浏览器关闭标签页提示:Scripts may close only the windows that were opened by it. 解决办法:通过open方法进行关闭. open( ...
- BFS:Meteor Shower(POJ 3669)
奔跑吧,傻牛 题目大意:这只Bessie的牛又要来闹事了,这次她的任务就是来躲流星雨,流星雨就是在一定时间会从天上砸到Bessie的所在的正方形区域内(Bessie在0,0的位置),然后砸下 ...
- CodeForces - 417A(思维题)
Elimination Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- 使用__declspec(export)导出C++类到DLL
使用举例: // File: SimpleDLLClass.h#ifdef SIMPLEDLL_EXPORT //在DLL工程属性-c/c++-预处理器-预处理器定义中添加此宏定义#define DL ...
- LINUX调优
一.Linux系统调优及安全设置 系统安装安全最小化原则说明 ◆安装linux系统最小化,即选包最小化,yum安装软件最小化. ◆开机自启动程序服务最小化,即无用的服务不开启. ◆操作命令最小化原则, ...
- Android之自定义控件深入
本文主要讲述两个知识点:popwindow的使用和通过继承View实现一个自定义控件,实现点击,手动按钮的效果. popwindow的使用 //定义 popupWindow popWin = new ...
- Freemarker中遍历List以及内置函数使用
在Freemarker应用中经常会遍历List获取需要的数据,并对需要的数据进行排序加工后呈现给用户. 那么在Freemarker中如何遍历List,并对List中数据进行适当的排序呢?一. Free ...
- 添加Java文档注释
一.在Eclipse中add javadoc comment的快捷键为: 快捷键为:ALT + SHIFT +J 二.Window-->Preferences-->General--> ...