Fix a rendering bug when resizing elements.