Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将浏览器重新调整为特定高度时更改固定位置_Javascript_Css_Positioning - Fatal编程技术网

Javascript 将浏览器重新调整为特定高度时更改固定位置

Javascript 将浏览器重新调整为特定高度时更改固定位置,javascript,css,positioning,Javascript,Css,Positioning,我目前对我的div使用固定位置,将其设置为停留在页面底部。但是,当我将浏览器的大小重新调整到div越过左侧导航的最小高度时,我遇到了一个问题 所以我想做的是,每当用户重新调整浏览器窗口的大小,使其略低于我的左导航的高度时,固定的位置将被删除或更改,这样它就不会与我的左导航重叠,浏览器将生成滚动到页面底部,其中那个div留下来了 那么我该如何解决这个问题呢?您可以通过$(document.height()获得浏览器高度,然后再进行检查 if($(document).height() > yo

我目前对我的div使用
固定位置
,将其设置为停留在页面底部。但是,当我将浏览器的大小重新调整到div越过左侧导航的最小高度时,我遇到了一个问题

所以我想做的是,每当用户重新调整浏览器窗口的大小,使其略低于我的
左导航的高度时,固定的位置将被
删除
更改
,这样它就不会与我的左导航重叠
,浏览器将生成滚动到页面底部,其中那个div留下来了


那么我该如何解决这个问题呢?

您可以通过
$(document.height()
获得浏览器高度,然后再进行检查

if($(document).height() > youwant){

   $('selector').css('bla','bla');
  //do you want

}
用js

 if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE

    myHeight = window.innerHeight;
  } 
if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'

    myHeight = document.documentElement.clientHeight;
  }
现在你可以检查了

 if(myHeight >bla){
   //your code
   }

您可以通过
$(document).height()获取浏览器高度,然后进行检查

if($(document).height() > youwant){

   $('selector').css('bla','bla');
  //do you want

}
用js

 if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE

    myHeight = window.innerHeight;
  } 
if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'

    myHeight = document.documentElement.clientHeight;
  }
现在你可以检查了

 if(myHeight >bla){
   //your code
   }
最好使用类来定义
阈值=500;
如果($(窗口).height()<阈值){
$('body').addClass('fixed');
}
最好使用类来访问
阈值=500;
如果($(窗口).height()<阈值){
$('body').addClass('fixed');
}

因为左侧导航的高度预计会发生变化,所以是否会有超过500的动态变化?是的,比如您希望它发生什么变化以及什么时候发生?好的,知道了。我需要得到那个div的高度。感谢@Praveen KumarYeah提供的
var threshold=$(“#id”).height()之类的!:)因为左边导航的高度预计会改变,所以会不会有超过500的动态变化?是的,比如你想什么时候改变?好的,知道了。我需要得到那个div的高度。感谢@Praveen KumarYeah提供的
var threshold=$(“#id”).height()之类的!:)