Generate the right number of columns for a grid layout for a page with variable numbers of columns