This element-rich water comes back up to the surface at 300 to 400 degrees and, when it meets seawater, releases the dissolved metals it contains. The metals, in the form of sulfides, settle out and build up on the ocean floor.
You can see this happening at the bottom of the ocean, where it creates black smokers:
In this type of deposit, the source of the metals is the ocean floor, they are carried by seawater heated by the magma, and the trap is the chemical reaction that happens when the fluids are released into the sea.