Leg Cramps: Cramps or spasms in the legs are painful contractions of the leg muscles. Sometimes, lying down for a long time can cause the muscles in your leg or feet to cramp. The dehydration as well as certain medications, overuse and diseases that affect the brain and nervous system can cause this. Other causes are compression of the calf muscles or those of the back of the knee, too much phosphorus, too little calcium or potassium, and low blood sugar in the body. All these are chemical imbalances in the blood.