头闻号

宜都盛大工贸有限公司

其他未分类|羧酸盐|羧酸|氟化物|硫酸盐|碳酸盐

首页 > 新闻中心 > 科技常识:css按钮自适应实现原理及代码
科技常识:css按钮自适应实现原理及代码
发布时间:2023-02-01 09:51:43        浏览次数:4        返回列表

今天小编跟大家讲解下有关css按钮自适应实现原理及代码 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关css按钮自适应实现原理及代码 的相关资料,希望小伙伴们看了有所帮助。

原理:利用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> 效果:

来源:爱蒂网