Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  59] [ 4]  / answers: 1 / hits: 9324  / 9 Years ago, fri, august 7, 2015, 12:00:00

In bootstrap I have a fixed top nav bar and fixed bottom nav bar. I want to show a large image in the background between the space of those two nav bars and I also want to cover the width of the window. How can I dynamically get the height between the navbars and the width of the window? The window size may change depending on device.So I need it dynamic


More From » jquery

 Answers
2
$(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';
});

});


this will be fine with if 0px padding and margin, if not also get that values and subtract from height_of_open_space before applying to img height


[#35068] Thursday, August 6, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jimmieo

Total Points: 515
Total Questions: 102
Total Answers: 110

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;