手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >用 CSS 让你的按钮(button)更加迷人
用 CSS 让你的按钮(button)更加迷人
摘要:查看演示我们用A包含一个SPAN标签来实现此效果:HTML:按钮文字设置按钮样式:a.button{background:transpare...

查看演示

我们用 A 包含一个 SPAN 标签来实现此效果:

HTML:

<a 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();

【用 CSS 让你的按钮(button)更加迷人】相关文章:

CSS完美代码的五个要点

正确使用CSS的height和min

用CSS3创建一个旋转可变色按钮

CSS让网页更容易设计与维护

CSS立体按钮效果

几款不错的按钮样式

CSS掌握定位的盒子模式

用CSS实现垂直居中的3种方法

使用Div+CSS布局设计网站的优点

如何用CSS让文字居于div的底部

精品推荐
分类导航