Dilemma:
We have two nested DIVs: an outer DIV with overflow: hidden and an inner DIV positioned absolutely. By default, the inner DIV will not adhere to the outer DIV's overflow behavior. How can we maintain this behavior without altering the outer DIV's position to absolute, which would disrupt our layout?
Solution:
To ensure the inner DIV respects the outer DIV's overflow property:
Example:
#outer { width: 200px; height: 200px; background-color: green; overflow: hidden; position: relative; // Make outer DIV relative } #inner { width: 50px; height: 50px; background-color: red; position: absolute; // Keep inner DIV absolute left: 250px; top: 250px; }
Additional Notes:
The above is the detailed content of How Can I Make an Absolutely Positioned Inner DIV Respect its Parent\'s Overflow:hidden Property?. For more information, please follow other related articles on the PHP Chinese website!