<style>
.father{
width:100%;
height:200px;
position: relative;
}
.son{
position: absolute;
top: 50%; //距离父元素高度
right:50%; //距离父元素右边的距离
transform: translateY(-50%); //垂直居中,向上移动自身距离的50%
//transform: translateX(-50%); //水平居中,向左移动自身距离的50%
//transform: translate(-50%,-50%); //水平垂直都居中
}
</style>
<body>
<div class="father">
<div class="son"> </div>
</div>
</body>