0

我正在尝试使用百分比创建垂直滚动 div,因为我正在为不同的设备高度开发但是,当我放置像素时我可以工作,但是当我放置百分比时它不适用

请看例子是

<div data-role="content"  >
    <div id="divChat" > 
    <div style="text-align:center"><div Class="ChatDate">2013-07-07</div></div>
    <div class="admin">Goal! Man city 1- Chealse 1<br/><span class="Time">16:42</span>     </div>

            <div class="bubble you"><div class="youName">Omer</div>Here?<br/>  <span class="Time">16:42</span></div>
                  <div class="bubble me">yes<br/><span class="Time">16:42</span></div>
         <div class="bubble me">yes<br/><span class="Time">16:42</span></div>
         <div class="bubble me">yes<br/><span class="Time">16:42</span></div>
         <div class="bubble me">yes<br/><span class="Time">16:42</span></div>
         <div class="bubble me">yes<br/><span class="Time">16:42</span></div>
         <div class="bubble me">yes<br/><span class="Time">16:42</span></div>
                     <div style="text-align:center"><div Class="ChatDate">2013-07-07</div></div>
    <div class="admin">Goal! Man city 1- Chealse 1<br/><span class="Time">16:42</span></div>

            <div class="bubble you"><div class="youName">Omer </div>Here?<br/><span class="Time">16:42</span></div>
                  <div class="bubble me">yes<br/><span class="Time">16:42</span></div>
    </div>
 <div data-role="footer"  style="bottom:0; position:absolute; left:0; width:100%">
    <div class="ui-grid-a"  > 
      <div class="ui-block-a" style="width:70%; padding-left:2px; ">
        <div data-role="fieldcontain"style=" padding:0px " >


        <textarea  data-mini="true"  data-role="none" style="width:90%; height:33px" data-theme="d"  name="chat_message" id="chat_message"  placeholder="Insert message here"></textarea>           </div>
      </div>
      <div class="ui-block-b" style="width:30%">

      </div>
    </div>
    </div>

我希望“divChat”处于固定高度并滚动 http://jsfiddle.net/vHLYj/

4

1 回答 1

0

您可以像这样将 inline-block 添加到您的#divChat:

#divChat {
   margin-top:2px;
   overflow-y:scroll; 
   height:50%;
   display: inline-block;
}

请注意,IE7 等旧浏览器不支持 inline-block。

在以下位置查看兼容性:

http://caniuse.com/inline-block

于 2013-10-19T10:03:06.710 回答