The shell structure underlying shape changes in neutron-rich nuclei near N=28 has been investigated by a novel application of the transient field technique to measure the first-excited state g factors in 38S and 40S produced as fast radioactive beams. There is a fine balance between proton and neutron contributions to the magnetic moments in both nuclei. The g factor of deformed 40S does not resemble that of a conventional collective nucleus because spin contributions are more important than usual.