html5以img标签为父标签
最外面的div引用flex布局,上下左右居中,此时最里面的p标签使用定位的话就会与以img标签为父标签一样的定位关系啦。
<style>
.body{
width:1200px;
height:675px;
display:flex;
align-items:center;
justify-content: center;
background-color: #f0f0f0;
}
.show{
max-width:1200px;
max-height:675px;
}
</style>
<div classname='body'>
<div style={{position:'relative'}}>
<img src='' classname="show" />
<p style={{position:'absolute',top:10,left:20}}>子元素</P>
</div>
</div>