We have two DIVs, one nested inside the other. If the outer DIV is not set to be absolutely positioned, then the absolutely positioned inner DIV will not respect the overflow hiding of the outer DIV.
#first { width: 200px; height: 200px; background-color: green; overflow: hidden; } #second { width: 50px; height: 50px; background-color: red; position: absolute; left: 250px; top: 250px; }
Is there a way to make the inner DIV follow the overflow hiding of the outer DIV without setting the outer DIV to be absolutely positioned (as this would break our overall layout)? Also, relative positioning is not an option for our inner DIV since we need to "highlight" a table TD.
#first { width: 200px; height: 200px; background-color: green; } #second { width: 50px; height: 400px; background-color: red; position: relative; left: 0px; top: 0px; }
Are there any other options?
What about using
position: relative
for external divs? In the example of hiding the inner div. Since top or left are not specified, it will not move within the layout.Set the outertoto
Like+0
Add Reply
P粉451614834
position: relative
and the innerposition: absolute
. This should work for you.