Jquery Height Q
- Started
- Last post
- 8 Responses
- ESKEMA0
ha. got it working... silly me.
Cheers
- orrinward20
That does work on JSFiddle. Bare in mind the window height in that is the height of the iframe, not the browser window.
- ESKEMA0
hmm. somehow this doesn't work on my side. maybe I'm coin something wrong.
when you say you've extracted the 700 to a variable, you mean I should add " var winheight = 700; " to the code?
it doesn't work either way..But thanks for your patience, I'll just use the one I have above, it's working and that's all I want.
- orrinward20
http://jsfiddle.net/orrinward/GN…
Something like that. This now returns the positioning to static if the window is greater than 700. I've also extracted the '700' to a local variable so you can control both from the one place
- ESKEMA0
sorry to bother, just want to know if what I have can be optimized somehow in a more streamlined version.
$(window).load(function() {
if ($(window).height() < 700){
$('#container').css("position", "absolute");
}
});$(window).resize(function() {
if ($(window).height() < 700){
$('#container').css("position", "absolute");
}
else { $('#container').css("position", "fixed");
}
});Thanks again!
- ESKEMA0
Great! Thanks Cheers Obrigado! and a very nice Xmas to you Sir.
- orrinward20
Sorry, part pseudo, part code there:
if ($(window).height() < 700){
$('#mydiv').css("position", "absolute");
}
- orrinward20
You can actually do this with CSS with @media.
In jQ though:
if (window.height < "700"){
$('#mydiv').css("position", "absolute")
}
- ESKEMA
Hey jquery gurus, how do I code
"If the browser window is lower than 700px, then #mydiv css position = absolute"?
Thanks