When deciding if the grid containers min size should be limited by a max size. Check for a max height or width depending on the dimension, instead of just always checking for a max width.