I would like to create two fixed divs on my webpage. First should be on the left, second on the right. I create some code but It doesn’t work perfect.
Demo here
I have no idea how to correct it. Any solutions?
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.
When the page scrolls, you’re setting a
position:fixedto your#asideand#bsideelements, by applying a classfixedandfixed2.Since the
position:fixedwhen aplied to#asideand#bside, takes them out of the document flow, the element#mainis floating as expected to the left.To avoid changing your current code, a simple solution would be to use a class to set certain styles to your
#mainelement, and have that class applied as needed:See this working Fiddle Example.
CSS
jQuery