Nighttime leg cramps often strike just as you're falling asleep or waking up. To prevent these involuntary contractions of your leg muscles, usually in the back of your lower leg, stretch your legs before you climb under the covers. Wear shoes with proper support. Untuck the covers at the foot of your bed. And drink plenty of fluids during the day.