This display shows a hollow sphere 10 meter inside radius and 11 meter outside radius. The total mass of the shell is 20,000kg. Inside the shell, starting in the vicinity of the origin is a 1kg test mass. You may click on the red test mass and use the mouse to drag it up and down the y axis. The shell is divided into two parts by a red line. That part above the location of the test mass is called the top part, below the test mass is the bottom part. The mass of each part and the coordinates of the center of mass of each part are shown on the display. The location of the center of mass of each part is shown as a green spot.
We can treat the force on the test mass from the top and bottom parts as though the entire mass of each part was at the center of mass for that part. It is clear from the symmetry of the situation that the center of mass of both parts will lie on the y axis. This display has a built in center of mass locator which calculates the center of mass of the two parts. You can see that as the test mass moves up the y axis, the top part gets smaller and its center of mass gets closer to the test mass and the bottom part gets larger and its center of mass moves farther from the test mass. The combination of these effects is to keep the total force on the test mass equal to zero even if we move the test mass off the origin. Of course we are free to choose any direction for the y axis since the object is spherically symmetric, so the same results occur whatever the direction we move the test mass off the origin.