在bootstrap中,我有一个固定的顶部导航栏和一个固定的底部导航栏。我想在背景中的那两个导航栏之间显示一个大图像,我也想覆盖窗口的宽度。如何动态获取导航栏和窗口宽度之间的高度?窗口大小可能会因设备而异,因此我需要动态设置
$(window).resize(function() {
var top_nav_height = $("#id_of_top_nav").height();
var bottom_nav_height = $("#id_of_bottom_nav").height();
var window_height = $(window).height();
var height_of_open_space = window_height - (top_nav_height+bottom_nav_height);
$("#id_of_img").css({
height:height_of_open_space+'px';
});
});
如果0px填充和边距,这将是很好的,如果不是,也获取该值并减去,height_of_open_space
然后应用于img
高度
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句