html – Bootstrap手风琴:当折叠或展开元素时如何避免页面滚动

前端之家收集整理的这篇文章主要介绍了html – Bootstrap手风琴:当折叠或展开元素时如何避免页面滚动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
尝试折叠或展开手风琴的元素时,我有意外的页面滚动。也许我只是在bootstrap网格系统中做错了?以下是页面示例:

如何避免这种刺激性的影响?
jsfiddle可用https://jsfiddle.net/Lfwvtyms/1/

<body>
<!--default navbar here-->
<main>
    <h1>Long long long long long long header header header header header header lng lasd lewq j</h1>
    <div class="container">
        <div class="row">
            <div class="col-xs-12">
                <div id="task-list">
                    <div id="accordion" role="tablist" aria-multiselectable="true" class="panel-group">

                        <div class="panel panel-default">
                            <div id="headingOne" role="tab" class="panel-heading"><h4 class="panel-title"><a
                                    data-toggle="collapse" data-target="#collapSEOne" href="#collapSEOne"
                                    aria-expanded="true" aria-controls="collapSEOne">First list</a></h4></div>
                            <div id="collapSEOne" role="tabpanel" aria-labelledby="headingOne"
                                 class="panel-collapse collapse in">
                                <ul class="list-group">
                                    <li class="list-group-item">Item1</li>
                                    <li class="list-group-item">Item2</li>
                                    <li class="list-group-item">Item3</li>
                                </ul>
                            </div>
                        </div>

                        <div class="panel panel-default">
                            <div id="headingTwo" role="tab" class="panel-heading"><h4 class="panel-title"><a
                                    data-toggle="collapse" data-target="#collapseTwo" href="#collapseTwo"
                                    aria-expanded="true" aria-controls="collapseTwo">Another list</a></h4></div>
                            <div id="collapseTwo" role="tabpanel" aria-labelledby="headingTwo"
                                 class="panel-collapse collapse in">
                                <ul class="list-group">
                                    <li class="list-group-item">Item1</li>
                                    <li class="list-group-item">Item2</li>
                                    <li class="list-group-item">Item3</li>
                                </ul>
                            </div>
                        </div>

                    </div>
                </div>

                <div id="someDiv">
                    <div class="row">
                        <div class="col-xs-12">
                            <div id="dummy">Div with fixed height here</div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</main>
<footer class="container-fluid">my footer here</footer>
</body>

解决方法

我有同样的问题(跳到顶部点击链接触发崩溃切换) href =“#”更改为href =“javascript:void(0);”它工作很好(切换崩溃,没有任何滚动到顶部)

猜你在找的HTML相关文章