I have a normal website page that looks like this:

How can I get the difference between the browser screen width and the right edge of #stuff relative to the browser screen width?
Basically I want to somehow change the width of #stuff to this value:

If I got it right it’s just mathematics. Let’s think in x and y. Your
stuffdiv has aninitial xand afinal x. Thefinal xcan be obtained byinitial x + width. Now you have the very final point ofstuffrelative to the screen you can use it to calculate the difference you are searching for.window width - final x = differenceYou can get:
initial x with
$("#stuff").offset().leftwidth of stuff with
$("#stuff").width()width of the window with
$(window).width()difference
$(window).width() - ($("#stuff").offset.left + $("#stuff").width())Here how this works: http://jsfiddle.net/SPL_Splinter/xKzvj/
Hope it helps. 🙂