【问题标题】:Fluid div next to fixed div固定 div 旁边的流体 div
【发布时间】:2014-01-08 20:52:11
【问题描述】:

我有Bootstrap framework 作为网站的基础。 现在,主要内容是 1000px 宽。 然后我有这个 100% 宽的区域,在其中我有 1000px 的区域。 但是……

  1. 左侧部分固定宽度为 290 像素。
  2. 右边的长部分是流体宽度,从左边部分的边界开始,到 100% 宽的容器结束的地方结束。
  3. 右侧长部分内部是710px的固定内容。

我想要流畅的宽度正确的内容。 图片滑块或谷歌地图之类的。

我认为基本的html应该是:

<div class="wide_container">
 <div class="container1000px">
  <div class="left290px">
  </div>
  <div class="rightFluid">
   <div class="right710px">
     But inside of this the image slider should be wider than 710px.
     And this website is responsive, too.
   </div>
  </div>
 </div>
</div>

非常感谢您的任何想法!

(Full image)

【问题讨论】:

标签: html css twitter-bootstrap


【解决方案1】:

将 .rightFluid 设置为 min-width:710px 并添加类 pull-right。

.rightFluid{
     min-width:710px;
}

<div class="rightFluid pull-right">

我认为,这应该可行。

您可以在此处查看参考:http://jsfiddle.net/ashishanexpert/B8L6L/

【讨论】:

  • 我不明白这将如何工作。问题是我有那个 1000px 的容器。实际上这个 1000px 容器的宽度取决于视口大小。因为这是响应式网站。我可以重新排列html。重要的是左边的内容是固定宽度的,并且应该总是与左边对齐 - 所以它会与顶部标题和内容的左行下方对齐。
  • 假设没有 right710px div。就是那种液体。但如果它在那个 1000px 的容器内,它仍然会受到限制。但是右边的内容必须在left div之后开始并向右展开。
【解决方案2】:

为此你需要使用像表格这样的结构 -->

右框将是流畅的

<div class="table row-fluid">

    <div class="left-box"></div>

    <div class="center-box"></div>

    <div class="right-box"></div>

</div>

<style>

.table {
    display : table;
}

.table > .div {
    display: table-cell;
}

.left-box {
    width: fixed-with;
}

.center-box {
    width: fixed-with;
}

</style>

【讨论】:

  • 这看起来像这样 - link to jsfiddle - 但我需要从其他内容开始的地方开始。这就是为什么我在容器内有左右。然后它也将居中对齐...
  • 我制作了更好的图像来解释我的问题。而不是该地图可以是图像滑块或其他任何东西。 See image
【解决方案3】:

在那张照片中,我看到你需要左侧的流动空间,我不知道宽度的规则应该是什么(流动 - 与父标签相关的东西),无论如何,这个链接可能会通过额外的关于如何的信息来帮助你这是工作, Check here

在那个链接中你看到了灰色部分,那个灰色部分是流动的,其他颜色部分得到了固定宽度,在任何表格中,如果你对某个表格单元格使用固定宽度并留下其他没有设置它们将填充的任何宽度提醒宽度 n 如果这个答案没有帮助,那一定是我对你的问题的误解

.table {
    display : table;
    height: 400px;
    width: 100%;     
    background-color: #808080;
}

.table > div {
    display: table-cell;
}

.right-box {
    width: 300px;
    background-color: blue;
}

.center-box {
    width: 100px;
    background-color: red;
}

【讨论】:

    【解决方案4】:

    好家伙,终于找到solution

    HTML:

    <div class="table">
    <div class="row hidden">
    <div class="cell"></div>
    <div class="cell-centered">fixed width 600px; row in yellow just to show cell alignment, actually goes "hidden"</div>
    <div class="cell"></div>
    </div>
    <div class="row">
    <div class="cell">
    </div>
    <div class="cell-fixed"><div class="fixed"><br>fixed width 200px<br><br></div></div>
    <div class="cell relative">
    <div class="outer absolute"><div class="inner absolute">100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100% 100%</div></div>
    </div>
    </div>
    </div>
    <div class="container"></div>
    

    CSS:

    body {margin: 0; text-align: center;}
    
    .table {width: 100%; position: fixed; top: 50px;}
    .row {display: table-row;}
    
    .cell {
    background: #ccc;
    display: table-cell;
    width: 50%;
    }
    
    .cell-centered {
    background: #aaa;
    display: table-cell;
    min-width: 600px;
    }
    .cell-fixed {
    background: #bbb;
    display: table-cell;
    min-width: 200px;
    }
    
    .fixed {
    background: #1dcf53 ;
    width: 200px;
    }
    
    .hidden .cell {background: #f0ff00 ;}
    .hidden .cell-centered {background: #e0ee00;}
    .relative {position: relative;}
    .absolute {position: absolute;}
    
    .outer {
    width: 100%;
    padding-right: 400px;
    right: 0;
    }
    
    .inner {
    background: #1dcfa6;
    width: 100%;
    right: 0;
    }
    
    .container {
    background: #eee;
    width: 600px;
    height: 300px;
    margin: auto;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多