• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Gah! Quick jQuery width help - going nuts.

morkus64

Limp Gawd
Joined
Jan 22, 2006
Messages
143
No clue why I can't get this to work - I've tried a million different ways.

Bascially just want to say for #divID take half of the window width, subtract 600px and make that the width.

If the window is less than 1200px wide, then the div width = 0. (Does that need anything special or will width automatically be 0 if the result of the math is negative?)
 
GOT IT. Anything wrong with this?

$(function(){
$('#searchbarrem').width($(window).width() * .5 - 600);

$(window).resize(function(){
$('#searchbarrem').width($(window).width() * .5 - 600);
});
});
 
That's true, although you add another div wrapper and set the left and right margins to 300px on that. Then set the child width to be 50% which should net you the same result. Its not quite a 100% clean solution though.

Then you can optimize it for smaller screens with media queries. That should get you where you're trying to go.
 
Back
Top