Trying to make a floating css menu. How do I get the floating div to float relative to parent container?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Instead of using
postion:fixedyou should be usingpostion:absolutefor #float-menu.Position fixed should be used when you want to fix something with respect to position of window (no matter you scroll how much or to where). Position absolute will deliver the same effect except it gets fixed to wherever it was rendered with respect to body. Putting position absolute with parent positioned to relative will deliver the effect which you are trying to achieve however it will not sustain if you scroll down.
Best solution would be to change the attribute position to absolute as soon as scrolltop crosses 100px using javascript.