Snap to face without changing y coordinates

Hello community. As the title says, I’m looking for a way to snap vertices of mesh A onto a separate mesh, let’s say mesh B, but without the vertices of mesh A changing their Y coordinates (they shouldn’t crawl up or down mesh B while trying to conform).

Specifically, I’m trying to put some skintight socks on a model’s legs and feet and when attempting snaps or shrink wrapping, the mesh inevitably starts crawling up the legs.

Is there such a method available? Or is there perhaps another way to achieve what I’m trying to do?