Did ancient Yogis float in the air and what is the method to do it?
First we should know our body is not just physical body, but has five sheaths (Pancha Kosha). What we see externally is Annamaya Kosha (food sheath). After death we shed Annamaya kosha and jiva with other four koshas (Sookshma Sareera or Subtle body) go to other realms, hell or heaven depending of Karma and Sukshma Sareera takes new physical body (rebirth) as mentioned in Chandogya Upanishad.
Yogis who know they are pure Consciousness (Atman) will never be subjected to laws of Space and Time and to laws of other four sheaths. They are no longer subjected to laws of physical body.
Yogananda explains the reason for all Siddhis or miracles in his book Autobiography of a Yogi (published in 1946).
Bhaduri Mahasaya was one such levitating sage described in chapter 7 of same book.
"Indeed it is true! He has lived indoors for the past twenty years. He slightly relaxes his self-imposed rule at the times of our holy festivals, when he goes as far as his front sidewalk! The beggars gather there, because Saint Bhaduri is known for his tender heart."
"How does he remain in the air, defying the law of gravitation?" (asks Upendra)
(Yagananda/Mukunda says) "A yogi's body loses its grossness after use of certain pranayamas. Then it will levitate or hop about like a leaping frog. Even saints who do not practice a formal yoga have been known to levitate during a state of intense devotion to God."
Yogananda further says their consciousness becomes mass free and they see whole cosmos as undifferentiated mass of light. Read Chapter 30 completely to get an overview of laws of miracles. I quote a few words of Yogananda to explain it in brief.
The consciousness of a perfected yogi is effortlessly identified, not with a narrow body, but with the universal structure. Gravitation, whether the "force" of Newton or the Einsteinian "manifestation of inertia," is powerless to compel a master to exhibit the property of "weight" which is the distinguishing gravitational condition of all material objects. He who knows himself as the omnipresent Spirit is subject no longer to the rigidities of a body in time and space. Their imprisoning "rings-pass-not" have yielded to the solvent: "I am He."
A yogi who through perfect meditation has merged his consciousness with the Creator perceives the cosmical essence as light; to him there is no difference between the light rays composing water and the light rays composing land. Free from matter-consciousness, free from the three dimensions of space and the fourth dimension of time, a master transfers his body of light with equal ease over the light rays of earth, water, fire, or air. Long concentration on the liberating spiritual eye has enabled the yogi to destroy all delusions concerning matter and its gravitational weight; thenceforth he sees the universe as an essentially undifferentiated mass of light.
Note: “The question: Did ancient Yogis float in the air and what is the method to do it?” is licensed by Stack Exchange Inc (https://hinduism.stackexchange.com/); user contributions licensed under CC BY-SA.