Adjust the layout of an HTML element based on its width