知道祖父母为overflow: auto
的情况下如何在其“祖父母”容器的顶部显示子元素>
.child { position: absolute; height: 200px; width: 150px; border: black solid 1px; background-color: pink; top: 10px; right: 0; } .parent { position: relative; height: 80px; border: black solid 1px; background-color: green; } .grand { position: relative; background-color: blue solid 2px; height: 80px; background-color: gray; overflow: auto; }
<!DOCTYPE html> <html> <head> <title>Parcel Sandbox</title> <meta charset="UTF-8" /> </head> <body> <div class="grand"> <div class="parent"> <div class="child"></div> </div> </div> </body> </html>
我如何在子代和祖父母的顶部显示子容器(不更改祖父母的溢出属性),如下图所示desired outcome
如何在其“祖父母”容器顶部显示子元素,知道祖父母已溢出:auto .child {position:absolute;高度:200px;宽度:...
您可以给祖父母position: relative;
和孙子-position: absolute; bottom: -20px; right: -20px;