Skyhawk 172/Cutlass 172
Flight Crew Student
Inflight Event / Encounter Weather / Turbulence
Flight Crew Diverted
Weather
I was completing my long X/C and the TAF's reported VFR conditions long after my proposed time of return to [departure airport].  I checked the weather forecast for the route of my flight and it also reported no fog at the proposed time of my enroute legs.  I encountered fog outside of the Class D Airspace below my aircraft by at least 1;500 feet upon my return to [departure airport].  I saw I could remain easily in VFR conditions; but still fly within the airspace.  I requested a Special VFR Clearance so I could attempt a straight-in approach to Runway 34; since fog was moving in quickly.  Upon my descent; I lost visual contact with the runway approximately 3 miles south of the approach end. I was above the fog in VFR condition and made the decision to break off my descent to the east and land at [another airport].  At no time was I in IMC; or not maintain visual contact with the ground.  The fog bank moved in sooner than predicted and was only over the airport runway.  The east and northeast of the airport had greater than 6 miles visibility; no fog and light haze.  I could see [a landmark] and I knew I was able to land at [the other airport]....  I maintained visibility and cloud clearance according to the limitations placed on my solo endorsement.
C172 Student Pilot; completing a long cross-country flight; encountered unforcasted fog upon return to departure airport and landed VFR at a nearby airport.