圆形按钮打破铬和野生动物园

时间:2010-08-14 05:23:25

标签: html css

为了创建圆形按钮,我使用左图像,右图像和图像条带三个图像。它的工作正常,但在safari和chrome中,正确的图像出现在下一行,我无法理解为什么会发生这种情况。所以有人请帮助我, 这是html标记及其CSS。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
        body{width: 980px;margin: 0 auto}
        .light_button a {background:url("images/center.png") repeat-x scroll 0 0 transparent;color:#000000;display:inline-block;font-size:16px;font-weight:bold;height:34px;line-height:29px;position:relative;text-align:center;text-decoration:none;}
            .light_button .lout {background:url("images/left.png") no-repeat scroll 0 0 transparent;float:left;height:31px;left:-8px;position:absolute;width:8px;}
            .light_button .rout {background:url("images/right.png") no-repeat scroll 0 0 transparent;float:right;height:31px;position:absolute;width:26px;}


            .light_button a.light_right_nav_first {background:url("images/center.png") repeat-x scroll 0 0 transparent;color:#000;display:inline-block;font-size:16px;font-weight:bold;height:31px;line-height:29px;position:relative;text-align:center;text-decoration:none;}
            .light_button a.light_right_nav_first .lout {background:url("images/p_left.png") no-repeat scroll 0 0 transparent;float:left;height:31px;left:-24px;position:absolute;width:24px;}
            .light_button a.light_right_nav_first .rout {background:url("images/r_right.png") no-repeat scroll 0 0 transparent;float:right;height:31px;position:absolute;width:26px;}




    </style>
  </head>
  <body>

      <div class="light_button">
          <div class="left">
              <a class="nav_first" href="#">
                  <span class="lout"></span>
                    home
                  <span class="rout"></span>
              </a>


          </div>


          <div class="right">
              <a class="light_right_nav_first" href="#">
                  <span class="lout"></span>
                    home
                  <span class="rout"></span>
              </a>


          </div>
      </div>



  </body>
</html>

1 个答案:

答案 0 :(得分:2)

不要将float和绝对定位结合起来。在您的情况下,您可能希望删除float并保留position:absolute。您left:-8px;width:8px已经.lout,您可以使用.rout属性为right执行类似的操作:right:-26px;width:26px

此外,由于您的左右图像将位于实际链接之外,因此您应该考虑为链接添加边距,以使图像不会重叠。