Creating dynamic grid layout with gaps control.