作家
登录
    用户名:  密码:   

用 CSS 让你的按钮(button)更加迷人

作者: 来源:www.28hudong.com 2012-11-19 22:29:45 阅读54次 我要评论

查看演示我们用 A 包含一个 SPAN 标签来实现此效果: HTML: 复制代码代码如下: <a class="button" href="#"><span>按钮文字</span></a> 设置按钮样式: 复制代码代码如下: <style type="text/css"> a.button { background: transparent url('bg_button_a.gif') no-repeat scroll top right; color: #444; display: block; float: left; font: normal 12px arial, sans-serif; height: 24px; margin-right: 6px; padding-right: 18px; /* sliding doors padding */ text-decoration: none; } a.button span { background: transparent url('bg_button_div.gif') no-repeat; display: block; line-height: 14px; padding: 5px 0 5px 18px; } </style> 为按钮添加点击样式: 复制代码代码如下: <style type="text/css"> a.button:active {background-position: bottom right; color: #000; outline: none; /* hide dotted outline in Firefox */ } a.button:active span { background-position: bottom left; padding: 6px 0 4px 18px; /* push text down 1px */ } </style> 由于 IE 下点击后不能还原到默认状态,因此,我们需要在标签里添加一段代码: <a class="button" href="#" onclick="this.blur(); return false;"><span>按钮文字</span></a> 如果你需要用它提交表单(FORM),那么可以在 onclick 里面添加一个提交语句,如:document.forms['theForm'].submit();

  推荐阅读

  全面兼容ie6,ie7,ie8,ff的最简单的css写法

还好,微软提供了这样一个代码: 复制代码代码如下: <meta http-equiv="x-ua-compatible" content="ie=7" /> 把这段代码放到<head>里面,在ie8里面的页面解析起来就跟ie7一模一样的了,所以,基本上可以无视ie8,>>>详细阅读


本文标题:用 CSS 让你的按钮(button)更加迷人

地址:http://www.17bianji.com/kaifa2/CSS/16701.html

14

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

54

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)