Valleys are often foggy when the sun rises because of a meteorological phenomenon known as radiation fog. Radiation fog occurs when the ground cools at night, causing the air near the ground to cool and become denser. This cooler and denser air sinks to the bottom of the valley, displacing the warmer air that was there before.
As the sun rises and begins to warm the ground, the air near the ground starts to warm up and rise. However, the air at the bottom of the valley remains cool and dense, and cannot rise as easily. This creates a temperature inversion, where the air at the bottom of the valley is cooler than the air above it.
As the warm, moist air from higher elevations moves into the valley, it cools rapidly and its moisture condenses into fog. This is why valleys are often foggy when the sun rises, especially during the autumn and winter months when the ground cools more rapidly at night.
The fog in valleys can be quite dense and last for several hours after sunrise until the sun's heat breaks down the temperature inversion and allows the cool air to mix with the warmer air above.