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

垂直弹簧垫片CSS

css
  •  1
  • TesX  · 技术社区  · 14 年前

    我是斯塔克新来的 溢流 . :-)


    height:"auto"
    但不起作用…:(

    例如:

    <div style="height:300px">
        <div style="height:50px">...</div>
        <div>The height of this div varies from page to page...</div>
        <div style="height:???">SPROING!!</div>
        <div style="height:50px">...</div>
    </div>
    

    编辑示例以更好地匹配我的需要。

    2 回复  |  直到 14 年前
        1
  •  0
  •   Pat    14 年前

    不幸的是,没有一种纯粹的CSS方法可以做到这一点,因为您要做的是:

    spring height = parent height - n children's height
    

    标记

    <div id="parent">
        <div id="top">...</div>
        <div id="spring">SPROING!!</div>
        <div id="bottom">...</div>
    </div>
    

    var leftover = $('#parent').height() - $('#top').height() - $('#bottom').height();
    $('#spring').height(leftover);
    

    action here .

        2
  •  0
  •   burningstar4    14 年前