父组件
.t-child-area {
position: relative
;
width: 100%
;
先要在父组件上用 position: relative 相对定位,之后再在子组件上用绝对定位调整位置。
子组件
.t-child {
position: absolute
;
width: 30%
;
margin-left: 5%
;
padding: 12px
;
在根据自己的位置进行调整,如果不在父组件上写相对定位,在浏览器大小发生变化时,因为是绝对定位,它不会跟随上面的变化而变化。