SOURCE

console 命令行工具 X clear

                    
>
console
<body >
<div class="parent">
   <div class="child"><p>dddsdfsdabcdd</p></div>
</div>
<body>
body {
    width: 100vw;
    height: 100vh;
}

.parent {
    position: relative;
    width: 200px;
    background: red;
}

.child {
    width: 100%;
    position: absolute;
    background: yellow;
}

.parent::before {
    width: 100%;
    position: absolute;
    content: '';
    background: green;
    padding-top: 100%;
}