龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > div+css/html >

如何用css制作有趣的按钮(最新译文)

时间:2012-12-29 08:41来源:未知 作者:admin 点击:
分享到:
如何用css制作有趣的按钮(最新译文) 作者:麦子翻译来源:http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html 这个技巧将教你如何用css做出漂亮的文本按钮,有活力的按钮将节

如何用css制作有趣的按钮(最新译文)

作者:麦子翻译   来源:http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html

这个技巧将教你如何用css做出漂亮的文本按钮,有活力的按钮将节省你很多制作图片的时间,也能让你一天的工作中成为一个快乐的人,让我们一起看看效果。

滑动门

为了让我们制作的按钮具有灵活性,我们必须要让背景图片自动适应按钮的文字的宽度,为此,我们要使用滑动门技术,将两张背景图片合并成一张背景图片。按钮将使用a标签和span标签,他们分别使用背景图片的不同部分,html代码是这样的:

<a class="button" href="#"><span>search</span></a>

没有什么超乎寻常的事发生,对吗?我们需要设计出简单明了的按钮,下面是我的想法:

每张图将包含按钮的两个状态,既普通和按下。我们把两种状态的图片交替的垂直排列,这个css技巧可以不用任何javascript脚本来完成变化,下面我们将使用滑动门技术,为了让按钮自适应文字的宽度,我们将图片做的宽一些,比如300px,高24px:

span                   a

按钮样式

最后我们将用css把这一切整合起来:

a.button {
background: transparent url(''images/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;
text-decoration: none;
}

a.button span {
background: transparent url(''images/bg_button_span.gif'') no-repeat;
display: block;
line-height: 14px;
padding: 5px 0 5px 18px;
}

<
精彩图集

赞助商链接