html - 内部 div 需要位于其他内容之上的右浮动 div

标签 html css twitter-bootstrap

想象一下,右侧面板 div 滑出到彼此相邻的两个其他 div 的顶部(左、右、100% 宽度)。它就像一个信息面板,用户可以滑出并阅读,然后关闭。

但到目前为止,我的尝试是生产一个包裹在其他 2 个下方的面板,而不是坐在它们上面。 Here's a fiddle .

如何让蓝色区域位于红色和绿色之上?请注意,红色绿色 div 实际上本身就是一个内部 div。

    <div class="row">
      <div class="col-xs-8">

        <div class="row">

          <div class="col-md-12">

            <div class="row">  

              <div class="col-md-12"> 

                <!-- These two div's need to remain side by side -->
                <div class="col-xs-8" style="background-color: green; float: left;">
                  Green
                </div>
                <div class="col-xs-4" style="background-color: red; float: right;">
                  Red
                </div>        

                <!-- This div needs to layer on top of the two divs above -->
                <div style="background-color: blue; color: white; float: right;">
                  Blue
                </div>

               </div>
            </div>        

          </div>
        </div>

      </div>

      <!-- This div needs to float to the right of all the content above -->
      <div class="col-xs-4" style="background-color: yellow;">
        Yellow
      </div>

    </div>

最佳答案

你需要把 position: relative; 放在父 div 上,然后你可以用 position: absolute; 调整蓝色 div 的位置 top/right/bottom/left 属性。

JSFiddle (我将你所有的 CSS 移到了类中,这样你就可以更好地了解发生了什么。)

关于html - 内部 div 需要位于其他内容之上的右浮动 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43544951/

相关文章:

JavaScript/Socket.io Web 应用程序不执行任何 JS 命令

html - 如何防止 div 在调整大小时重叠

html - 如何在此布局中使内容100%高度和等高列?

html - 使用 Twitter Bootstrap 排列单选按钮答案

html - CSS:将边框应用于选项卡焦点图像

java - 使用 JSoup 从 HTML 中提取数据

javascript - 对齐父项下的下拉列表内容

jquery - 将 youtube 视频包装在响应图像 "frame"中,使用 LazyYT.js 进行延迟加载

html - Bootstrap 3 : Missing gutters

html - BS3 - img 响应类 - 为什么没有最大高度?