The downward force of air under very strong high pressure aloft presses down on the marine layer keeping it confined near the coast where very cool, foggy weather is typical. Inland, temperatures rise under the same high pressure.
As high pressure aloft decreases in strength, the downward force decreases allowing the marine layer to penetrate farther inland. The clouds are located near the top of the marine layer so at the beach the fog lifts to a lower cloud deck. Further inland, fog is located at the leading edge of the inland push of the cooler air.
Low pressure aloft allows the marine layer to deepen to as much as 6,000 feet (2000 meters). The fog is confined to the mountain tops and passes. In the lower elevations, the marine air begins to warm as it is modified by the heat rising from the ground. The cooler air moves over the coastal mountains and through the passes into the interior valleys.