css - 2个 float 容器在同一条线上

标签 css css-float

我在这里看到了很多关于 float 的问题,但他们帮不了我。

图片:http://img818.imageshack.us/img818/7289/ewd.png
蓝色框相对页面居中,红色框在蓝色的左侧。 我需要红色和蓝色框位于同一顶行(以隐藏绿色)。

这是 html:

<article class="post">

  <aside class="post-meta">
    <img src="img.png">
  </aside>

  <section class="post-content">
    Content of the post.
  </section>

</article>

这是 scss:

.post {
  clear: both;

  .post-meta {
    position: relative;
    float: left;
    width: 150px;
    left: -150px;
  }

  .post-content {
    float: right;
  }
}

感谢您的帮助!

最佳答案

试试这个:-

.post {
    position: relative;

.post-meta {
    background-color: red;
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 200px;
}
.post-content {
    background-color: yellow;
    margin-left: 200px;
}
        // keep the size of margin-left and width of .post-meta equal...
    }

工作非 scss 演示:- http://jsfiddle.net/UwQDT/1/

谢谢...

关于css - 2个 float 容器在同一条线上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17157750/

相关文章:

javascript - 添加/删除 CSS 会导致 IE9 增加表格的高度

javascript - 如何将百分比分配给 CSSStyleDeclaration 的属性

javascript - 如何使用 jQuery 在条件规则中设置 HTML 属性?

jquery - dlmenu 滚动不允许访问最后几个元素

HR-Line 旁边的 Css float

html - 将 div float 到上方的垂直空间 - ie7 问题

css - 检测内联/ float 元素被推到新行

html - 什么是更快的性能明智? IE 过滤器或 Sprite /图像

html - 全宽左对齐列表

css - 在 CSS 中使用 float 后,Listnumber <ol><li> 不会在 IE9 中显示