div始终正确,所有浏览器

时间:2013-03-11 15:15:54

标签: css css3 cross-browser

我只是创建div的下一个css代码,始终是正确的:

#button > .right{
  background-position: -268px 1415px;
  height: 180px;
  position: fixed;
  right: -90px;
  top: 40%;
  width: 263px;
 -webkit-transform                : scale(0.23);
 -moz-transform                   : scale(0.23);
 -o-transform                     : scale(0.23);
 -ms-transform                        : scale(0.23);
 transform                        : scale(0.23);
}

我在firefox中尝试这个代码很好,但是当我在其他浏览器中尝试时,却找不到它。

任何想法?

pdt:这是网址http://supboat.herokuapp.com/

编辑:这段代码很好,问题是因为这个div位于其他div中,位置为:relative。

2 个答案:

答案 0 :(得分:1)

您的问题很容易解决。您的设置right:-90px;表示div被移出可见屏幕90px。您将宽度设置为263px,然后将其缩放到0.23。这是约60px(263 * 0.23)。这意味着你的div就在那里,但他的左边框距离你的可见视口大约30像素。

答案 1 :(得分:0)

嘿只需计算屏幕宽度,然后更新按钮左坐标值。

例如: -

<button id="right"><button>

<script>
    var x=$(window).width();
    var right=document.getElementById("right");
    right.style.position="absolute";
    right.style.left=x+"px";
</script>

x是屏幕的总宽度,然后您已将“x”分配给按钮的左侧坐标...:)