Ask Your Question
2

How can I keep my logo and background from moving despite using position attributes of "fixed" and "relative" in CSS and HTML?

asked 2023-05-27 00:21:10 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-05-27 00:42:02 +0000

woof gravatar image

There are a few reasons why your logo and background might still be moving despite using position attributes of "fixed" and "relative" in CSS and HTML. Here are some possible solutions:

  1. Check that you have specified the correct element for the position attribute. Make sure that you are targeting the element that you want to be fixed or relative, and that there are no conflicting CSS rules that are overriding your position attribute.

  2. Make sure that your logo and background are contained within a parent element that has a fixed position. If your logo and background are contained within a relative or static position parent element, they will still move with the page.

  3. Check that your logo and background are not being affected by other CSS rules. Sometimes, other rules such as float, clear, or margin can affect the position of elements on the page, even if you have specified a fixed or relative position attribute. Try removing other CSS rules temporarily to isolate the issue.

  4. Try using a different position value, such as "absolute" or "sticky". Depending on the layout of your page, one of these values might work better for keeping your logo and background in place.

  5. Consider using JavaScript to dynamically position your logo and background. Depending on the complexity of your layout, JavaScript might be the best option for achieving the desired effect.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-27 00:21:10 +0000

Seen: 8 times

Last updated: May 27 '23