Looking for the title of a 50's or '60's children's sci-fi story where a greedy child (boy?) of the future eats too many food pills and swells so much he floats up into the sky.
In Roald Dahl's 1964 classic Charlie and the Chocolate Factory (and in both version of the movie) there are two scenes you might be conflating in this memory.
First, the (excessively) gum-chewing girl gets a piece of gum that includes a complete seven-course meal - though Wonka warns her (faintly) that it's still in testing. When she reaches the dessert, blueberry pie, she begins to swell, and turn blue (like a berry), eventually having to be rolled off to juicing in an attempt to keep her from exploding.
Later, Charlie (and his grandfather, at least in the first movie) take unauthorized sips of a soda drink that fills them with lighter than air gas and causes them to float in the air, coming dangerously close to a huge exhaust fan before they find they can belch to release the lifting gas and lower themselves.
In L Frank Baum (of wizard of oz fame)'s novel The Master Key there are the two elements you mention, but they are separate.
a silver box of food tablets, each one of which provides sufficient nourishment for a whole day a "small tube" which can direct "an electric current" at a foe, rendering him unconscious for the period of one hour a wristwatch-sized transportation device, which allows the wearer to fly at any height and travel at high speeds in any direction, when it is working properly. It is, however, somewhat fragile and becomes damaged and unreliable during Rob's adventures, creating predicaments for him.
It is also available in full here