CSS读取图片坐标实现图片背景
2009-03-12 18:10
645 查看
CSS读取图片坐标实现图片背景,只需加载一次图片,就可以实现整个页面的背景,现在很多门户网站都在使用,比如网易163、腾讯等,以下是126邮箱登陆页面的登陆按钮部分:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用CSS实现的一张图完成的导航条</title>
<style>
ul,li{ list-style:none; float:left;}
body{ font-size:12px; line-height:1.6; font-family:Verdana, "宋体", Arial; text-align:center;}
#info li{ margin-left:4px; margin-top:15px;}
#info a {display:block;text-align:center; padding-left:15px;
padding-top:2px;padding-bottom:1px;background-image:
url(http://www.jscode.cn/Uploadfile/200682494749491.GIF);
background-repeat: no-repeat;color: #000; width:47px; cursor:hand; text-decoration: none;}
#job a:link,#job a:visited{background-position: -62px 0px;}
#eve a:link,#eve a:visited{background-position: -124px 0px;}
#oth a:link,#oth a:visited{background-position: -186px 0px;}
#car a:hover ,#car a:active {background-position: 0px -22px; color:#fff;}
#job a:hover ,#car a:active {background-position: -62px -22px; color:#fff;}
#eve a:hover ,#car a:active {background-position: -124px -22px; color:#fff;}
#oth a:hover ,#car a:active {background-position: -186px -22px; color:#fff;}
</style>
</head>
<body>
jyjyjyjy
<div id="info">
<ul>
<li id="car"><a href="#" target="_blank"><span>
游 戏</span></a></li>
<li id="job"><a href="#" target="_blank"><span>
娱 乐</span></a></li>
<li id="eve"><a href="#" target="_blank"><span>
菜 单</span></a></li>
<li id="oth"><a href="#" target="_blank"><span>
好 玩</span></a></li>
</ul>
</div>
</body>
</html>
<style type="text/css"> .inp_L1,.inp_L2{background:url('http://www.zzsky.cn/build/images/200851603033.jpg') no-repeat} .inp_L1{width:67px;height:23px; background-position:-4px -4px;border:0;color:#464646;line-height:23px} .inp_L2{width:67px;height:23px; background-position:-4px -30px;border:0;color:#464646;line-height:23px} </style> <input type="submit" id="input_btn1" name="enter.x" value="登 录" onMouseOver="this.className='inp_L2'" onMouseOut="this.className='inp_L1'" tabindex="4" class="inp_L1"> |
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用CSS实现的一张图完成的导航条</title>
<style>
ul,li{ list-style:none; float:left;}
body{ font-size:12px; line-height:1.6; font-family:Verdana, "宋体", Arial; text-align:center;}
#info li{ margin-left:4px; margin-top:15px;}
#info a {display:block;text-align:center; padding-left:15px;
padding-top:2px;padding-bottom:1px;background-image:
url(http://www.jscode.cn/Uploadfile/200682494749491.GIF);
background-repeat: no-repeat;color: #000; width:47px; cursor:hand; text-decoration: none;}
#job a:link,#job a:visited{background-position: -62px 0px;}
#eve a:link,#eve a:visited{background-position: -124px 0px;}
#oth a:link,#oth a:visited{background-position: -186px 0px;}
#car a:hover ,#car a:active {background-position: 0px -22px; color:#fff;}
#job a:hover ,#car a:active {background-position: -62px -22px; color:#fff;}
#eve a:hover ,#car a:active {background-position: -124px -22px; color:#fff;}
#oth a:hover ,#car a:active {background-position: -186px -22px; color:#fff;}
</style>
</head>
<body>
jyjyjyjy
<div id="info">
<ul>
<li id="car"><a href="#" target="_blank"><span>
游 戏</span></a></li>
<li id="job"><a href="#" target="_blank"><span>
娱 乐</span></a></li>
<li id="eve"><a href="#" target="_blank"><span>
菜 单</span></a></li>
<li id="oth"><a href="#" target="_blank"><span>
好 玩</span></a></li>
</ul>
</div>
</body>
</html>
相关文章推荐
- CSS代码实现鼠标移过更换背景图片
- CSS实现HTML背景图片拉伸铺满示例
- php实现的css文件背景图片下载器代码
- css实现背景图片自适应大小
- HTML背景图片拉伸铺满 CSS实现
- <web前端>当背景图片为渐变色图片时,为避免浏览器大小问题,可以选择使用<CSS>实现渐变色,教程如下
- Android 实现从本地读取图片更改聊天背景
- css 实现背景图片不跟着滚动条滚动而滚动
- CSS中背景图片的坐标之使用说明及css中把所有背景图都放在一张图片上减少图片服务器的请求次数问题(转)
- css实现网页背景图片自适应
- 使用js操作css实现js改变背景图片
- css实现评论文本框加背景图片
- CSS实现背景透明而背景上的文字图片不透明
- css实现背景图片渐变
- 不用背景图片,只用css代码实现面包屑样式
- CSS基础实例:CSS实现带背景图片的文字链接的方法
- 利用Dreamweaver自身功能,快速准确测绘图片上的元素坐标位置,并快速用到CSS背景坐标设置当中去
- 【css实践】全屏实现背景图片
- div+css实现鼠标放上去,背景跟图片都会变化。
- css 实现背景图片拉伸