The electronic and magnetic structures of thin films with intermediate electron densities, described by the planar uniform jellium model, are investigated using the local spin density approximation. A fully polarized ferromagnetic state, which has a periodic electron density along the perpendicular direction to the surfaces of a film, is the most stable among possible states. In such a state, electrons are self-confined to the valleys of a periodic potential induced by the electrons. This suggests that a 3D electron gas reveals phase transitions from an unpolarized or fully polarized fluid to a 1D electron-self-confined state, to a 2D one, and finally to a 3D Wigner crystal, as the electron density is lowered.