代码之家  ›  专栏  ›  技术社区  ›  sgrif

并排潜水,无浮标或position:absolute

  •  3
  • sgrif  · 技术社区  · 16 年前

    我想找到一种不使用浮点数或浮点数来并排放置div的方法position:absolute. div将有一个设置的宽度,其中可能有浮动元素。这是一个CMS,用户将能够拖动内容元素来组织它们。它们不必是div,我只是不知道还有哪种类型的HTML标签能更好地工作。

    基本上,最终的结果是一个CMS,用户可以通过拖动内容元素来组织内容元素。不幸的是,如果你想做任何事情,包括把div放在另一个下面,所有的东西都会下降到上面最高的div下面,即使它可以放在其他东西下面。i、 e.3个元素,其中2个元素应堆叠在左侧,第三个元素应堆叠在右侧,其高度介于两者之间。

    内联块是出了,因为它是不支持的IE(虽然我很想成为一个迪克,只是有铬框架要求…),并没有工作为此目的无论如何。

    4 回复  |  直到 16 年前
        1
  •  2
  •   ScottS    16 年前

    我有点困惑,你提到拖动元素,但你的标题声明你不想使用position:absolute as 解决方案。。。据我所知,大多数脚本在拖动过程中都会使用它,所以为什么不使用它来定位并排放置它们呢?

        2
  •  1
  •   naiquevin    16 年前

    当一个元素被拖放到同一个ul中时,它在ul中的索引就会改变。当它被拖过uls时,它将从这个列表中删除并附加到另一个列表中,并按照案例1的方式排列。现在有个主意。。。我得试试

        3
  •  0
  •   David Thomas    16 年前

    position:absolute , display: inline-block float )就是用桌子。

    <table>
        <tr>
            <td><div id="div1">...content...</div></td>
            <td><div id="div2">...content...</div></td>
        </tr>
    </table>
    

    <div id="container">
        <div id="div1">...content...</div>
        <div id="div2">...content...</div>
    </div>
    

    #container {display: table; } /* you might need another child div with 'display: table-row' but I can't remember off-hand */
    #div1 {display: table-cell; width: 50%; /* other css */}
    #div2 {display: table-cell; /* width: 50%; other css */}
    

    这是我能想到的最好的方法了,我不喜欢把表格用于非表格的目的。但每个人都有自己的=/

        4
  •  0
  •   amfeng    16 年前

    你只是在寻找一种拖放和组织内容的方法吗?你看过jqueryui的“Sortable”吗?

    http://jqueryui.com/demos/sortable/

    推荐文章