【问题标题】:Fixed-width div with % width div?具有%宽度div的固定宽度div?
【发布时间】:2010-07-26 10:34:51
【问题描述】:

是否可以使用固定宽度的 div 和扩展的 div?比如:

<div style="float:left; width:200px">
</div>

<div style="float:left; width:100%"> // expand please
</div>

<div style="position:fixed; width:320px">
</div>

我希望中间的 div 只是扩大宽度,并在放置左右 div 之后占用剩下的任何东西。如果我给它们中的每一个都指定一个以 % 为单位的宽度,它就可以正常工作,但是当对某些使用固定宽度时,它们会在浏览器框架变小时等时开始重叠,

谢谢

【问题讨论】:

标签: html css


【解决方案1】:

怎么样:

<html>
  <body>
    <div style="float:left;width:200px;background:red">&nbsp;
    </div>

    <div style="float:right; width:320px;background:blue">&nbsp;
    </div>

    <div style="background:black">&nbsp;
    </div>
  </body>
</html>

【讨论】:

    【解决方案2】:
    <div style="left:0;width:30px;"></div>
    <div style="left:30px;right:0;"></div>
    

    您可能需要将它们设置为绝对定位和父相对位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-25
      • 2016-02-02
      • 1970-01-01
      • 2014-08-28
      • 2015-10-14
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      相关资源
      最近更新 更多