Nested absolutely positioned elements can exhibit unexpected behavior in CSS. Consider this scenario:
Q: Why is #3rd absolutely positioned relative to #2nd instead of #1st?
A: Because position: absolute within an absolutely positioned element resets the relative position for its children.
This property effectively overrides the relative positioning of #1st for #3rd, making it position absolute relative to its direct parent, #2nd.
To achieve your desired behavior, where #3rd is absolutely positioned relative to #1st, you would need to make #3rd a direct child of #1st.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3