Just as it works when you connect 2 computers to a switch via straight through cables. Ping works (for the most part) at layer 3. It has no relation to what the physical layer 1 offers. Once you have the right connectivity in layer 1 and 2 then layer 3 should work.
May be you wanted to ask: "How crossover works ?" Am I right?