We experimentally demonstrate the transverse confinement of light in the presence of a longitudinally periodic photonic potential with vanishing average. In agreement with Kapitza's original findings in classical mechanics, we confirm that light undergoes a transverse localization due to the action of an effective potential proportional to the square of the first derivative of the potential. Experiments are performed based on (1+1) D synthetic dimensions realized in a fiber loop system, allowing for complete control of the transverse and longitudinal distributions of the potential.