Using resize function instead of changing styles