ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
<div class="parent"> <div class="child"></div> </div> .parent{ width: 400px; height: 300px; background: red; } child{ margin-top:100px; width: 100px; height: 100px; background: #2dae2d; } 子元素作为父元素的第一个元素,给他margin-top没用,他的父元素变动 解决方法 before元素里面的第一个子元素 .parent::before{ content: ""; display: table;//display:block;无效 }