2011-12-07 56 views
1

我有一个CSS,只显示垂直滚动条而不显示水平滚动条。IE7和IE8之间的兼容性问题

我的CSS是,

div.rightSide { 
display: inline; 
float: right; 
height: 234px; 
margin: 5px 0; 
overflow-y: auto; 
position: relative; 
vertical-align: middle; 
visibility: inherit; 
width: 300px; 
z-index: 6; 
} 

它将按预期在IE8和Mozilla 3.6,但是当我测试相同的IE7,也越来越显示垂直滚动条。那么为了克服这个问题我应该怎么做?

编辑

添加我的HTML代码。

<body> 
    <div> 
     <div id="contentColumn"> 
      <div class="overviewPage"> 
       <div class="instructionContent" id="sample_id"> 
        <div class="overviewBackground" style="z-index: 3;"> 
         <p class="sidebar_body"> 
          <img align="center" border="0" height="244" 
           src="../images/product/sample.jpg" width="752" /> 
         </p> 
        </div> 
        <div class="rightSide"> 
         <div class="unitOverview"> 
          <p class="body"> 
           <span class="bold">Unit 1 Overview</span> 
          </p> 
          <div class="sectionContents"> 
           <div class="subhead_pri"> 
           <!-- My title goes here --> 
           </div> 
           <div class="sectionBody" style="overflow:hidden;width:100%"> 
            <p class="body"> 
            <!-- My content Goes here --> 
            </p> 
           </div> 
          </div> 
         </div> 
         <div class="vendor">ID: vendor1</div> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</body> 

感谢, Jeya

+0

你可以把HTML代码?因为我的答案取决于html代码,只适用于类“rightSide”及其容器使用的div,并且如果将css放在容器中会更好。 –

+0

已添加我的HTML代码。 – i2ijeya

+0

谢谢,但是那个名为“instructionContent”的div的div在CSS中有宽度吗? –

回答

0

实验与您的内容。 overflow-y:auto表示'如果必须只显示垂直滚动条'。显然IE7认为你的内容足够高,它需要滚动条。

1

overflow-x: hidden;添加到您的CSS以及。

+0

帮我几天前 – lvil

+0

我已经加了上面的代码片段,结果仍然一样。 – i2ijeya

0

默认情况下,IE7将您的容器视为overflow: auto。 您需要另行说明。 尝试添加overflow: hidden之前overflow-y: auto,在我的情况帮助。