instead of adjusting on window resize only, detect container resizing. (Maybe using some kind of polling solution.)