3

使用 twitter 引导程序,我正在尝试创建一个手风琴,它在展开时将占据80%屏幕height。到目前为止,我还没有找到一种方法让它与%. 固定高度可以正常工作,但如果不进行计算来确定屏幕高度的 80% 将是多少,这是毫无意义的。

<div class="accordion" id="accordion2">
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle btn-warning btn" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                RETURNED RESULTS
                </a>
            </div>
            <div id="collapseOne" class="accordion-body collapse in">
                <div class="accordion-inner">
                Anim pariatur cliche...
                </div>
            </div>
        </div>
        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle btn btn-danger" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                WRITE RESPONSE
                </a>
            </div>
            <div id="collapseTwo" class="accordion-body collapse">
                <div class="accordion-inner">
                Anim pariatur cliche...
                </div>
            </div>
        </div>
    </div>

css

#admin-response{
    width:60%;
    min-width:400px;
    margin-left:10%;
    height:85%;
    float:left;
}
#admin-response .accordion-inner{
    width:100%;
    background-color:#fff;
    height:100%;
    box-shadow:2px 2px 12px rgba(0, 0, 0, 0.15);
    -moz-box-shadow:2px 2px 12px rgba(0, 0, 0, 0.15);
    -webkit-box-shadow:2px 2px 12px rgba(0, 0, 0, 0.15);
}

#admin-response .accordion-body.in.collapse{
    min-height:85%;
}​

我创建了一个小提琴,显示了我在本地拥有的东西

http://jsfiddle.net/bpSjn/1/

手风琴模型与 twitter 给出的示例相同。对 css 进行了一些小的更改。

4

1 回答 1

0

JSFiddle here with simple jQuery to measure window Height

var viewportHeight = $(window).height() * 0.8;
$('.accordion').css('max-height', viewportHeight);
$('.accordion').css('min-height', viewportHeight);

http://jsfiddle.net/bpSjn/31/

Also note the deleted heights in the CSS

于 2013-03-14T04:47:55.680 回答