At the simplest level, it can be explained as the result of hot air in the Central Valley and cool ocean currents offshore. But scientists are learning that it is also influenced by more complex global weather forces. Winds and Earth's rotation push ocean surface south and away from the coast. Cold water from ocean depths rises to surface. Cold water cools the air above it, causing fog.
Fog is drawn inland toward the warm Central Valley.
Winds around the Pacific High, circling clockwise owing to the Earth's rotation, push the ocean surface down the coast 1. The resulting current causes an upwelling of cold water from below 2. That upwelled water cools the air above it, causing its moisture to condense into fog. Meanwhile the warm air in the sun-heated Central Valley rises and is gradually replaced by the cool ocean air, drawing the fog across the bay and toward the valley 3. The fog dwindles or disappears, resulting in clear skies in the Bay Area.