ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 给唯一子元素margin-top,父元素跟随移动 ~~~ .parent{ background: darkslateblue; width: 400px; height: 400px; /* overflow: hidden; */ } .child{ background: salmon; width: 100px; height: 100px; margin-top: 100px; } ~~~ ~~~ <div class="parent"> <div class="child"></div> </div> ~~~ ![](https://box.kancloud.cn/4a84a0a882cfa6518876ca95665f18fc_669x767.png) **解决方案:** 1.**伪元素** ~~~ .parent::before{ display: table; content: ""; } ~~~ 2.**给父元素overflow:hidden**