当使用white-space:nowrap时,scrollLeft在IE和Firefox上不起作用

时间:2015-08-01 14:22:26

标签: javascript html css

我的代码不适用于IE和Firefox,但适用于Chrome: IE上的滚动左侧值和Firefox = 0,为什么?

<body style="direction:rtl">
<div style="width:520px; margin:0 auto; background:#eee; height:120px;overflow:scroll " id="BookSliderContent">
    <div style="white-space:nowrap;">
        <div style="width:100px;height:100px; background-color:lightblue;margin:20px;display:inline-block">1</div>
        <div style="width:100px;height:100px; background-color:lightblue;margin:20px;display:inline-block">2</div>
        <div style="width:100px;height:100px; background-color:lightblue;margin:20px;display:inline-block">3</div>
        <div style="width:100px; height:100px; background-color:lightblue; margin:20px; display:inline-block">4</div>
        <div style="width:100px;height:100px; background-color:lightblue; margin:20px; display:inline-block;">5</div>
    </div>
</div>

<script type="text/javascript">
  var  ScrollLeft = 0;
  ScrollLeft = document.getElementById("BookSliderContent").scrollLeft;
  alert(ScrollLeft);
</script>

Result

0 个答案:

没有答案