【问题标题】:Width procent and overflow scroll宽度 procent 和溢出滚动
【发布时间】:2012-12-13 14:15:16
【问题描述】:

我有一个 div,里面有一些代码(如 textarea),我想从父元素修复到 99%。没关系,但如果代码太大,我需要放置 overflow-x:scroll 以不从父元素中退出。

因为我使用的是width:99%,所以我不能使用overflow-x:scroll。

我不想放 width:700px 或 500 或其他什么,因为我现在没有客户端分辨率,我真的想看到这个 div 的最大宽度。

对不起,我的语言不好。

请给点建议?

谢谢。

【问题讨论】:

  • 为什么不能使用overflow-x:scroll
  • 因为这个 div 有 width:99%

标签: css scroll width overflow


【解决方案1】:

抱歉,我忘记了 white-space:pre。

试试这段代码,你会看到:

<style>
div {width:99%; border:1px solid grey; white-space:pre; overflow:x-scroll}
</style>

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

【讨论】:

    【解决方案2】:

    喜欢这个吗?

    div {width:99%; border:1px solid grey; white-space:pre; overflow:auto;}
    

    【讨论】:

      【解决方案3】:
          <style>
          div {width:99%;
       border:1px solid grey;
       white-space:pre;
       overflow:x-scroll}
          </style>
      
          <div>
          test test test test test
          </div>
      

      【讨论】:

        【解决方案4】:

        请原谅我的错误,因为我没有给出所有代码。

        Stil 不起作用,因为父元素 (table -> td) 很灵活:

        <style> 
        div {width:99%; border:1px solid grey; white-space:pre; overflow:auto;}
        </style>
        
        <table cellspacing="0" cellpadding="0">
        <tr>
        <td> some stuff here </td>
        <td>
        <div>
        test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test 
        </div>
        </td>
        </tr>
        </table>
        

        如果有人有其他建议...

        【讨论】:

          猜你喜欢
          • 2015-05-16
          • 1970-01-01
          • 2013-12-30
          • 1970-01-01
          • 2017-03-02
          • 2013-03-30
          • 1970-01-01
          • 2017-05-15
          • 2021-06-06
          相关资源
          最近更新 更多