zoukankan      html  css  js  c++  java
  • css实现不固定长度圆角按钮,兼容所有浏览器

    圆角按钮,圆润平滑、看起来让你看舒服,在网页设计中也必不可少,以前如果我要用圆角按钮是直接把图片切下来,如果有多种宽度的按钮,就切多个图片,然后一个一个的写css,显然,这种方法有缺点,通用性不好,而且多个css有很有重复代码,有点浪费资源。

    后面终于找到一个通用的,可实现不固定宽度的圆角按钮方法,也是用图片作背景,不过要在按钮外面加一个标签,如div,然后把div和button,同时设置一张背景图片,不同的是背景图片位置不同,外面div标签为:background-position:left,  里面button为:background-position:right;

    效果如下:

    以下是代码,相信你一看就会明白的。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>css不固定长度圆角按钮,兼容所有浏览器</title> 
    <style type="text/css">  
    .submit{background:#fff url(statics/images/but.png) left top no-repeat;height: 27px;padding:0px 0px 0px 3px; margin:0px 0px 0px 0px;  float:left;display:inline-block;  overflow:hidden;}
    .submit input{background:#fff url(statics/images/but.png) right top no-repeat;height:27px; margin:0px; border:none;padding:0px 10px 0px 7px;font-size:14px; color:#fff;font-weight:bold; width:auto;overflow:visible;}
    </style>
    </head>
    
    <body>
    <div class="submit"><input type="submit" value="测试" id="Button2"  class="btn"  /></div> <br /><br />
    <div class="submit"><input type="submit" value="再测试" id="Button3"  class="btn"  /></div><br /><br />
    <div class="submit"><input type="submit" value="再再测试" id="Button4"  class="btn"  /></div><br /><br />
    <div class="submit"><input type="submit" value="再再再测试" id="Button5"  class="btn"  /></div><br /><br />
    <div class="submit"><input type="submit"  value="再再再再测试" id="Button6"  class="btn"  /></div><br /><br />
    <div class="submit"><input type="submit" value="再再再再再测试" id="Button7"  class="btn"  /></div><br /><br />
    <div class="submit"><input type="submit" value="再再再再再再测试" id="Button8"  class="btn"  /></div><br /><br />
    <div class="submit"><input type="submit" value="再再再再再再再测试" id="Button9"  class="btn"  /></div>
    </body>
    </html>

    背景图片:

    好了,圆角按钮实现了,其余神马a标签,span什么的都是一个原理。

  • 相关阅读:
    mysql指定字符位置截取字符串(多行重复信息进行合并)
    数据库按某字段去重查询结果集做法
    poi从数据库导出百万数据并写入excel
    自定义消息弹框以及跳转
    Django使用distinct报错:DISTINCT ON fields is not supported by this database backend
    Mysql】Mysql中CURRENT_TIMESTAMP,CURRENT_DATE,CURRENT_TIME,now(),sysdate()各项值的区别
    HTML文件直接在浏览器打开和本地服务器localhost打开有什么区别?
    pip下载加速的方式
    Python字符串格式化方式之format
    chmod: changing permissions of 'xxx': Operation not permitted
  • 原文地址:https://www.cnblogs.com/manongxiaobing/p/2625301.html
Copyright © 2011-2022 走看看