【发布时间】:2014-03-11 05:28:28
【问题描述】:
我在我的网站(在 wordpress 上)上使用 JS 脚本来在滚动时获取顶部标题。 我现在正在处理移动和 ipad 的媒体查询,因为存在一些问题...
我想在移动设备和 ipad 上禁用此 JS,以便我的标题保持相对。 我找不到办法 有人可以帮忙吗?
这是我的 JS 代码:
$(function () {
// Check the initial Poistion of the Sticky Header
var stickyHeaderTop = $('#stickyheader').offset().top;
$(window).scroll(function () {
if ($(window).scrollTop() === stickyHeaderTop+1) {
$('#stickyheader').hide();
console.log('p');
}
if ($(window).scrollTop() > stickyHeaderTop) {
$('#stickyheader').fadeIn(500).css('position','fixed');
$('#stickyalias').css('display', 'block');
var mT = $('#stickyheader').css('height');
$('#stickyheader').next('.post').css('marginTop', mT);
}else{
$('#stickyheader').css({
position: 'relative',
});
$('#stickyheader').next('.post').css('marginTop', '0');
}
});
});
还有我的css:
#header {background-color: #f8f8f8;top: 0;padding-top: 20px;}
#stickyheader { width: 100%;padding-top:10px;top: 0;z-index: 1000;padding-bottom: 10px;line-height: 24px;position:relative;background-color: #f8f8f8;}
#unstickyheader {height:auto;}
我的媒体查询 css:
/* Media queries!
-------------------------------------------------------------------------------*/
/*IPAD*/
@media screen and (max-device-width : 1024px) {
}
/*IPHONE*/
@media screen and (max-device-width : 568px) and (min-device-width : 320px) {
#menu-menu {list-style:none;font-size: 35px;font-weight: 700}
}
最后是一个 JS 小提琴:
非常感谢您的帮助,
【问题讨论】:
标签: ios css media-queries javascript