gpt4 book ai didi

css - 在响应 View 上禁用粘性侧边栏

转载 作者:行者123 更新时间:2023-11-28 01:28:10 25 4
gpt4 key购买 nike

来自标题本身。我想在移动 View /响应 View 期间禁用粘性侧边栏。目前,我可以通过添加此 JQUERY 代码来创建 float 侧边栏。HTML

<div  class="sidebar col-md-4">
<div class="">
<div class="widget">
<div class="total-payment">PHP 2,500.00</div>
<ul class="list-icon list-icon-orange">
<li><i class="fa fa-calendar info-icon"></i><span class="info-label">Earliest available date: 14 Jun 2018</span></li>
<li><i class="fa fa-hourglass-2 info-icon"></i><span class="info-label">48 Hours Confirmation</span></li>
<li><i class="fa fa-flag-o info-icon"></i><span class="info-label">Join Group</span></li>
</ul>
<p class="info-p">
Fill up this form and received a confirmation within 24 hours. LAST MINUTE BOOKING for next day must be made on or before 3:00PM.
</p>
<div class="row">
<div class="col-md-12">
<div class="form-group text-center">
<button type="button" class="btn btn-block btn-orange" style="font-size:24px;">Book</button>
</div>
</div>
</div>

</div>
</div>
</div>

JQUERY

$(function() {
var $sidebar = $(".sidebar"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 115;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({
marginTop: $window.scrollTop() - offset.top + topPadding
});
} else {
$sidebar.stop().animate({
marginTop: 0
});
}
});

});

它在大分辨率下运行良好,但我似乎无法在移动 View 中禁用它。任何帮助,将不胜感激。谢谢

最佳答案

所以根据建议,我设法用一些 if 语句修复了它,它成功了:)

var isMobile = false;

if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
isMobile = true;
}

if (isMobile != true) {
$(function() {
var $sidebar = $("#sticky"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 115;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({
marginTop: $window.scrollTop() - offset.top + topPadding
});
} else {
$sidebar.stop().animate({
marginTop: 0
});
}
});
});
}

关于css - 在响应 View 上禁用粘性侧边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51137689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com