An automatic opening and closing device (10) for a container (12) comprises a closure flap (30) within the container and a pivot arm (40) with a weighted portion (44). When the container (12) is in a first position, the centre of mass of the weighted portion (44) is offset horizontally and vertically from the pivot point of the pivot arm (40) and acts to bias the closure flap (30) to close an opening in the container (12). When the container (12) is rotated in a first direction to a second position, the weighted portion (44) causes the pivot arm (40) and closure flap (30) to rotate relative to the container in a second direction opposite to the first direction, to bias the closure flap away from the opening. In the first position, the weighted portion (44) is offset vertically by a greater distance than it is offset horizontally. A locking mechanism may also be provided, which is operable to the user to keep the container closed even when tilted.