您的位置:首页 > Web前端 > CSS

用css样式定义圆角背景图片按钮根据文字自适应宽度的方法

2012-11-16 14:47 597 查看
CSS样式:

.setBottom a,.setBottom span,.popTishi .popIcon{background:url(../images/button.png) no-repeat;}

.setBottom{height:30px;position: relative;line-height:30px;}
.setBottom span{ position:absolute;height:30px;width:3px; display:inline-block;top:0; cursor:pointer;}
.setBottom span.spanLeft{left:-3px;}
.setBottom span.spanRight{right:-3px;}
.setBottom a{padding:0 20px; display:inline-block;}

.btnBlue a{ background-position:center -180px}
.btnBlue span.spanLeft{background-position:left -180px;}
.btnBlue span.spanRight{ background-position:right -180px;}
.btnBlue a:hover{background-position:center -150px;}
.btnBlue a:hover .spanLeft{background-position:left -150px;}
.btnBlue a:hover .spanRight{background-position:right -150px;}
.btnBlue a,.btnBlue a:visited{color:#fff;}
.btnBlue a:hover{color:#005383;}

html用法:

<div class="setBottom btnBlue fl">
<a href="#">
<span class="spanLeft"></span>
<span class="spanRight"></span>
搜索
</a>
</div>

样式中图片如下图所示:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: