>  기사  >  웹 프론트엔드  >  css按钮自适应_html/css_WEB-ITnose

css按钮自适应_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 12:33:381525검색

原理:利用a标签和i标签各自一个背景组合成为按钮,达到自适应。

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <style type="text/css">        .btn a{text-decoration:none;}        .btn{display: inline-block; background: url(s_btn.png) no-repeat 0 0; height: 22px; line-height: 22px; color: #666; vertical-align:top;}        .btn i{display:block;font-style: normal; font-size: 12px; padding: 0 10px; background:url(s_btn.png) no-repeat right -22px; }        .btn:hover{text-decoration: none;color:#4c8136;background-position: 0 -44px;}        .btn:hover i{background-position: right -66px;}        .btn:active{background-position: 0 -88px;}        .btn:active i{background-position: right -110px;}        .btn_disabled, .btn_disabled:hover{background: url(../img/s_btn.png) no-repeat 0 -132px;cursor: default;}        .btn_disabled i, .btn_disabled:hover i, .s_btn_disabled:active i{background-position: right -154px;color:#999;}        </style>    </head>    <body>        <a href="#" class="btn"> <i>这是按钮</i> </a>        <a href="#" class="btn"> <i>按钮</i> </a>    </body></html>

效果:

             

 

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.