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
$(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
Requires jquery:
var viewport = {
width : $(window).width(),
height : $(window).height()
};
//can access dimensions like this:
//viewport.height
Though you won't always get perfect results, different devices behave differently and this gives the viewport dimensions, not the screen dimensions.
Alternatively you could check the width of a data-role="page"
element to find the device-width (since it's set to 100% of the device-width):
var deviceWidth = 0;
$(window).bind('resize', function () {
deviceWidth = $('[data-role="page"]').first().width();
}).trigger('resize');
I am using a wrap bootstrap theme to style my rails 3.2 app. After including all the stylesheet files and javascript files, I see that some inline editing(which uses javascript and Jquery) is not ...
I am using a wrap bootstrap theme to style my rails 3.2 app. After including all the stylesheet files and javascript files, I see that some inline editing(which uses javascript and Jquery) is not ...
I'm new to JavaScript but I've written some code that as far as I can see is formatted correctly however when I add the data elements in it breaks the code but I cannot see why as according to the ...
I'm new to JavaScript but I've written some code that as far as I can see is formatted correctly however when I add the data elements in it breaks the code but I cannot see why as according to the ...
I have an app im building with phonegap. I'm listening for touchstart/ touchend events to make it responsive. Sometimes, the event listener for the touchend will fire, but then, for e.g, an input ...
I have an app im building with phonegap. I'm listening for touchstart/ touchend events to make it responsive. Sometimes, the event listener for the touchend will fire, but then, for e.g, an input ...
so I'm using innerHTML to try to add a dom element with a count variable, I'm console.logging the dom element and the property innerHTML changed to what I want, but it's not rendering to the page/ ...
so I'm using innerHTML to try to add a dom element with a count variable, I'm console.logging the dom element and the property innerHTML changed to what I want, but it's not rendering to the page/ ...