• 守望幸福

  • 地瓜的博客
  • 首页
  • 登录
  • overflow:visible后的button

    [艺术pk技术]
    post by cosa / 2009-4-23 23:26 Thursday

          button在ie6、ie7下会有个随着文字长度增减而改变的"内补丁"(暂且这么叫吧)。这个内补丁很特殊,不管你怎么写margin:0;padding:0;都去不掉,唯一的解决办法是overflow:visible。如果这时候再定义button的height、line-height就会发现在ie下button居然变高了,而且宽度也不跟ff下不一样:

    点击在新窗口中浏览此图片

    代码:

    <!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=gb2312" />
    <title>overflow:visible给button的困扰</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <style type="text/css">
    <!--
    span {display:inline-block;*display:inline;height:27px;zoom:1;border:1px solid #251E9D;}
    button {padding:0px 10px;height:27px;line-height:27px;border:1px solid #EFEFEF;font-size:12px;background:#87B516;overflow:visible}
    -->
    </style>
    </head>

    <body >
    <span><button>测试按钮</button></span>
    </body>
    </html>
    [/hcode]
    [separator]
          因为赶这做项目,这个问题就先搁一般了,今天研究了下,发现原来只要把lin-heihgt改成padding就ok了,是不是真的ok了呢?,其实还没有,ff跟ie下的高度还是有差别的,文字居中对齐也是个问题:

    [img][attach]43[/attach][/img]

    [hcode]<!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=gb2312" />
    <title>overflow:visible给button的困扰 -- 高度不一致</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <style type="text/css">
    <!--
    span {display:inline-block;*display:inline;zoom:1;border:1px solid #251E9D;}
    button {padding:3px 10px;border:1px solid #EFEFEF;font-size:12px;background:#87B516;overflow:visible}
    -->
    </style>
    </head>

    <body >
    <span><button>测试按钮</button></span>
    </body>
    </html>



    到这里,除了hack我还有其它的方法吗?

    标签: button overflow:visible
    « javascript静态方法 | flash跨域调用外部js»

    引用地址:

    发表评论:

  • 搜索

  • 分类

    • 艺术pk技术(35) 订阅该分类
    • 琐事(12) 订阅该分类
  • 链接

    • 19楼UED
    • 红茶
    • 丁子
    • huskyf
    • 候鸟的碎舞
    • 王云
  • 存档

    • 2010年1月(2)
    • 2009年12月(1)
    • 2009年11月(1)
    • 2009年10月(1)
    • 2009年9月(1)
    • 2009年6月(1)
    • 2009年4月(1)
    • 2009年3月(1)
    • 2008年12月(1)
    • 2008年9月(2)
    • 2008年8月(3)
    • 2008年7月(3)
    • 2008年6月(6)
    • 2008年5月(6)
    • 2008年4月(2)
    • 2008年3月(8)
    • 2008年2月(6)
    • 2008年1月(1)
订阅Rss
Powered by emlog 查询备案号,请拨120,谢谢合作