简体   繁体   English

折叠后如何自动滚动到页面底部?

[英]How can I auto scroll to bottom of the page after collapse?

I have this element that uses bootstrap collapse. 我有使用引导崩溃的元素。 When I click on "header" of this élément, it opens and a scrollbar appears but I like to appears being at the bottom. 当我单击此元素的“标题”时,它会打开并显示一个滚动条,但我希望显示在底部。

I try many solution from stackoverflow, but none seem to work. 我尝试了许多来自stackoverflow的解决方案,但似乎没有任何效果。 I can do this ? 我可以做这个 ?

<div class="row">
    <div class="col-sm-12">
        <div id="panel-profil" class="panel panel-info">
            <div id="panel-heading-profil" class="panel-heading text-center">
                <a id="link-heading-profil" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo"
                   aria-expanded="false" aria-controls="collapseTwo" onclick="changeArrowProfil()">
                    <div class="row">
                        <div id="triangleUn" class="col-sm-1">
                            <span id="triangle1" class="glyphicon glyphicon-triangle-bottom"></span>
                        </div>
                        <div class="col-sm-10">
                            <span class="fa fa-truck fa-1"></span> Profil du véhicule

                        </div>
                        <div id="triangleDeux" class="col-sm-1">
                            <span id="triangle2" class="glyphicon glyphicon-triangle-bottom"></span>
                        </div>
                    </div>
                </a>
            </div>
            <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
                <div id="panel-body-profil" class="panel-body">
                    <label class="text-info" for="sel1">Longueur du véhicule :</label>
                    <form class="form-horizontal">
                        <div class="form-group form-group-sm">
                            <div class="col-sm-1"><img src="../img/B10a.png" height="35" width="35" ></img></div>
                            <input class="col-sm-2 control-label inputConstraint"
                                   for="formGroupInputSmall" type="text" value="6.00 m" autocomplete="off" id="value_length" readonly/>
                            <div class="col-sm-8 sliderConstraint"
                                 for="formGroupInputSmall">
                                <input type="range" min="0" step="1" max="3" value="0"
                                       id="value_length_slide"
                                       onchange="changeValue('length')" />
                            </div>
                        </div>
                    </form>
                    ...
                    ...
                </div>
                <div class="row" id="valid-param">
                    <div class="col-sm-12">
                        <button id="btn-valid-param" onclick="modifierProfileSaisi();" type="submit" class="btn btn-success btn-sm btn-block" > Valider les paramètres</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

If your using an onClick event, then within that onClick, write this line of code, 如果您使用的是onClick事件,请在该onClick中编写以下代码,

window.scrollTo(0,document.body.scrollHeight);

This will scroll you to the bottom of the page. 这会将您滚动到页面底部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM