div+css实现自适应宽度按钮_经验交流
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了div+css实现自适应宽度按钮_经验交流,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2369字,纯文字阅读大概需要4分钟。
内容图文
![div+css实现自适应宽度按钮_经验交流](/upload/InfoBanner/zyjiaocheng/416/bf9443c012d94f19b51fe9cbe0f303c2.jpg)
先来看张图片:
原理就是通过背景的左对齐和右对齐用A标签和span标签组合出一个完整的圆角矩形。再通过hover标签去滑动图片。而你只需要一张图片:
ok,看看代码吧。
CSS:
代码如下:
*{margin:0; padding:0;} body{padding:10px; font-size:12px;} h1{margin:0; padding:10px 0; font-size:14px; font-weight:bold;} a{background:url(1.gif) left 0; color:#fff; text-decoration:none; height:30px; float:left; cursor:hand; margin:0 5px 0 0;} a:hover{background:url(1.gif) left -30px;height:30px;} a span{background:url(1.gif) right 0; padding:7px 8px 7px 0; margin:0 0 0 8px; float:left; height:16px;} a:hover span{background:url(1.gif) right -30px; color:#000; padding:7px 8px 7px 0; margin:0 0 0 8px; height:16px; }
HTML:
代码如下:
<body> <h1><strong>CSS自适应宽度圆角按钮 @5key.net</strong></h1> <a href="#"><span>首页</span></a> <a href="#"><span>不是首页</span></a> <a href="#"><span>他也许是首页</span></a> <a href="#"><span>但他一定不是首页</span></a> <a href="#"><span>好了,就这样把。别扯了~</span></a> </body>
演示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>CSS自适应宽度按钮</title> <style> *{margin:0; padding:0;} body{padding:10px; font-size:12px;} h1{margin:0; padding:10px 0; font-size:14px; font-weight:bold;} a{background:url() left 0; color:#fff; text-decoration:none; height:30px; float:left; cursor:hand; margin:0 5px 0 0;} a:hover{background:url() left -30px;height:30px;} a span{background:url() right 0; padding:7px 8px 7px 0; margin:0 0 0 8px; float:left; height:16px;} a:hover span{background:url() right -30px; color:#000; padding:7px 8px 7px 0; margin:0 0 0 8px; height:16px; } </style> </head> <body> <h1><strong>CSS自适应宽度圆角按钮</strong></h1> <a href="" target="_blank"><span>首页</span></a> <a href="" target="_blank"><span>不是首页</span></a> <a href="" target="_blank"><span>他也许是首页</span></a> <a href="" target="_blank"><span>但他一定不是首页</span></a> <a href="" target="_blank"><span>好了,就这样把。别扯了~</span></a> </body> </html>
以上就是div+css实现自适应宽度按钮_经验交流的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!
内容总结
以上是互联网集市为您收集整理的div+css实现自适应宽度按钮_经验交流全部内容,希望文章能够帮你解决div+css实现自适应宽度按钮_经验交流所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。