css - 为什么这个 div 容器会阻止另一个 div 容器向右浮动?

标签 css html containers

我知道答案很简单,它可能是一个小的 CSS 属性,但我试图在不在这里询问的情况下找到解决方案,但运气不佳..

在一个 div 容器中有两个 div 容器,它们玩起来不太好。

一个定位在父div的右上角 float ,它不会让任何其他容器 float 到它的右边。

我尝试了 display:inlinedisplay:inline-block 但没有成功...

这是代码,虽然有些东西告诉我答案很简单,你不需要它!:

父级 div、右上角的 div 和试图向右浮动的可怜的 div:

    #um-home-section4   {
    width:100%;
    height:300px;
    background-color: green;
}

#um-title-right {
    float:right;
    width:500px;
    height:50px;
    margin-right:20px;
    margin-top:20px;
    background-color: fuchsia;
}

#take-me-there  {
    float:right;
    margin-top:240px;
    margin-right:0px;
    height:50px;
    width:100px;
    background-color: gray;
}




<div id="um-home-section4">
                <div id="um-title-right"></div>
                <div id="take-me-there"></div>

            </div>

最佳答案

您只需更改 HTML 中的顺序:

<div id="um-home-section4">
  <div id="take-me-there">
  </div>
  <div id="um-title-right">
  </div>
</div>

查看此演示 http://jsfiddle.net/Rk4mr/11/

关于css - 为什么这个 div 容器会阻止另一个 div 容器向右浮动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19886029/

相关文章:

c++ - 不使用 for 循环传递数据

php - 在生成水印 PHP GDLib 时调整图像大小

html - 闯入:避免-第一个元素(IE,Edge,Firefox)忽略CSS

html - 如何使背景只适合指定的 float child

html - 自定义按钮颜色未在浏览器中显示

javascript - 如何在不使用 jQuery 的情况下重写这一行?

javascript - 使用 css 和 javascript 从 asp.net 中的文本框中删除默认焦点

javascript - 如何在 null 上设置颜色输入的值

html - 如何在容器周围的 twitter bootstrap 中制作背景图像

extjs - 如何让滚动条出现在 Rally 纸板组件中?