CSS自适应宽度圆角按钮
2013-01-10 13:11
525 查看
1.背景图片实现
Html代码:
a { display: block; float:left; margin-left:5px; height: 37px;line-height: 37px; background: url(btn_bg.png) no-repeat 0px 0px; color: #d84700; text-decoration: none; padding-left:18px; }
a span { display:block; background: url(btn_bg.png) no-repeat right 0px; padding-right:20px;}
a:hover { background: url(btn_bg.png) no-repeat 0px -37px;}
a:hover span{ background: url(btn_bg.png) no-repeat right -37px;}
Html代码:
<p>
<a href="#"><span>免费注册</span></a>
<a href="#"><span>登录</span></a>
<a href="#"><span>自适应宽度</span></a>
</p>
原理就是做一个足够宽的背景,a和span都用同一张背景图,文字左侧部分显示的是a的背景,文字本身和右侧部分显示的是span的背景,拼接成一个按钮。
2.CSS3 火狐和Chrome实现
Html代码:
.button1{
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
-moz-box-shadow:0 1px 0 rgba(0,0,0,0.3);
-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.3);
box-shadow:0 1px 0 rgba(0,0,0,0.3);
background: -moz-linear-gradient(19% 75% 90deg, #E0E0E0, #FAFAFA);
background: -webkit-gradient(linear, left top, left bottom, from(#FAFAFA), to(#E0E0E0));
color:#4A4A4A;
float:left;
font-family:arial,helvetica,sans-serif;
font-size:17px;
font-weight:bold;
padding:10px 15px;
text-shadow:1px 1px 0 rgba(255, 255, 255, 0.7);
}
.button1:hover{
background: -moz-linear-gradient(19% 75% 90deg,#D6D6D6, #FAFAFA);
background: -webkit-gradient(linear, left top, left bottom, from(#FAFAFA), to(#D6D6D6));
}
Html代码 :
<p><a class="button1">渐变圆角按钮</a></p><br />
效果:
Html代码 :
.button7{
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
background: -moz-linear-gradient(19% 75% 90deg,#F0DEB8, #FDF0D1, #fff 100%);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#F0DEB8), color-stop(.3,#FDF0D1));
color:#836d4d;
float:left;
font-family:arial,helvetica,sans-serif;
font-size:15px;
font-weight:bold;
padding:6px 70px;
border: 1px solid #d4c198;
}
.button7:hover{
background: -moz-linear-gradient(19% 75% 90deg,#EBD9B4, #F2E6C8, #F5F5F5 100%);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F5F5F5), to(#EBD9B4), color-stop(.3,#F2E6C8));
}
<a class="button7">站长网</a>
Html代码:
a { display: block; float:left; margin-left:5px; height: 37px;line-height: 37px; background: url(btn_bg.png) no-repeat 0px 0px; color: #d84700; text-decoration: none; padding-left:18px; }
a span { display:block; background: url(btn_bg.png) no-repeat right 0px; padding-right:20px;}
a:hover { background: url(btn_bg.png) no-repeat 0px -37px;}
a:hover span{ background: url(btn_bg.png) no-repeat right -37px;}
Html代码:
<p>
<a href="#"><span>免费注册</span></a>
<a href="#"><span>登录</span></a>
<a href="#"><span>自适应宽度</span></a>
</p>
原理就是做一个足够宽的背景,a和span都用同一张背景图,文字左侧部分显示的是a的背景,文字本身和右侧部分显示的是span的背景,拼接成一个按钮。
2.CSS3 火狐和Chrome实现
Html代码:
.button1{
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
-moz-box-shadow:0 1px 0 rgba(0,0,0,0.3);
-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.3);
box-shadow:0 1px 0 rgba(0,0,0,0.3);
background: -moz-linear-gradient(19% 75% 90deg, #E0E0E0, #FAFAFA);
background: -webkit-gradient(linear, left top, left bottom, from(#FAFAFA), to(#E0E0E0));
color:#4A4A4A;
float:left;
font-family:arial,helvetica,sans-serif;
font-size:17px;
font-weight:bold;
padding:10px 15px;
text-shadow:1px 1px 0 rgba(255, 255, 255, 0.7);
}
.button1:hover{
background: -moz-linear-gradient(19% 75% 90deg,#D6D6D6, #FAFAFA);
background: -webkit-gradient(linear, left top, left bottom, from(#FAFAFA), to(#D6D6D6));
}
Html代码 :
<p><a class="button1">渐变圆角按钮</a></p><br />
效果:
Html代码 :
.button7{
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
background: -moz-linear-gradient(19% 75% 90deg,#F0DEB8, #FDF0D1, #fff 100%);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#F0DEB8), color-stop(.3,#FDF0D1));
color:#836d4d;
float:left;
font-family:arial,helvetica,sans-serif;
font-size:15px;
font-weight:bold;
padding:6px 70px;
border: 1px solid #d4c198;
}
.button7:hover{
background: -moz-linear-gradient(19% 75% 90deg,#EBD9B4, #F2E6C8, #F5F5F5 100%);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F5F5F5), to(#EBD9B4), color-stop(.3,#F2E6C8));
}
<a class="button7">站长网</a>
相关文章推荐
- CSS自适应宽度圆角按钮
- CSS自适应宽度圆角按钮
- CSS自适应宽度圆角按钮
- CSS自适应宽度圆角按钮
- CSS:浅谈自适应宽度圆角按钮实现
- CSS背景图片自适应文字宽度圆角按钮
- 圆角自适应宽度按钮的css实现
- CSS:浅谈自适应宽度圆角按钮实现
- CSS自适应宽度圆角按钮
- CSS自适应宽度圆角按钮
- [CSS]自适应宽度圆角按钮
- css圆角背景图片按钮-自适应内容大小
- 自适应宽度圆角按钮,导航,用到了滑动门技术
- 漂亮的自适应宽度的多色彩CSS图片按钮
- [CSS]自适应宽度按钮
- JS+CSS实现自适应选项卡宽度的圆角滑动门效果
- 【荐】CSS用一张背景图实现自适应宽度的圆角菜单
- CSS基于单张背景图实现自适应宽度的圆角菜单效果代码
- 实现自适应宽度圆角按钮的方法