纯CSS实现的当鼠标移上图片添加阴影效果代码
作者:bea
<html> <head> <title>CSS给图片添加阴影</title> <style> *{padding:0;margin:0;} body{background:#E8EDF1;padding:20px;} #profileAvatar {overflow:hidden;zoom:1;} #profileAvatar i{float:left;visibility:hidden;background:u
<html>
<head>
<title>CSS给图片添加阴影</title>
<style>
*{padding:0;margin:0;}
body{background:#E8EDF1;padding:20px;}
#profileAvatar {overflow:hidden;zoom:1;}
#profileAvatar i{float:left;visibility:hidden;background:url(http://files./demoimg/200912/avatar.gif) 0 0 no-repeat;}
#profileAvatar i i{background-position:100% 0; }
#profileAvatar i i i{background-position:0 100%;}
#profileAvatar i i i i{padding:0 5px 6px 0;background-position:100% 100%; }
#profileAvatar img{visibility:visible;display:block;padding:3px;border:1px solid #ccc;background:#fff;}
</style>
</head>
<body>
<div id="profileAvatar">
<i><i><i><i>
<a href="http://"><img src="http:///images/logo.gif" width="215" id="image" onmouseover="show()" onmouseout="show()" /></a>
</i></i></i></i>
</div>
鼠标移上去显示圆滑的阴影
<input type="button" value="缩小图片" onclick="document.getElementById('image').width -=10;" />
</body>
<script type="text/javascript">
var imgBg=document.getElementById('profileAvatar').getElementsByTagName('i')
function show(){
for(i=0;i<imgBg.length;i++)
{
if(imgBg[i].style.visibility=='visible')
imgBg[i].style.visibility='hidden';
else
imgBg[i].style.visibility='visible'
}
}
</script>
</html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- javascript 处理事件绑定的一些兼容写法
- javascript 事件加载与预加载
- Javascript 键盘keyCode键码值表
- JQuery与iframe交互实现代码
- jquery 弹出登录窗口实现代码
- 使用jQuery获取radio/checkbox组的值的代码收集
- Jquery 高亮显示文本中重要的关键字
- JQuery 写的个性导航菜单
- JavaScript中出现乱码的处理心得
- js 页面刷新location.reload和location.replace的区别小结
- CSS+Jquery实现页面圆角框方法大全
- HTA版JSMin(省略修饰语若干)基于javascript语言编写
- javascript下arguments,caller,callee,call,apply示例及理解
- 关于Aptana Studio生成自动备份文件的解决办法
- window.js 主要包含了页面的一些操作
- js 效率组装字符串 StringBuffer
- JS+CSS实现的一种交互体验 表单页面
- javascript 仿开心网好友印象功能(点击文字弹出印象框)
- JavaScript 未知高度元素垂直居中实现代码