下面是子元素样式,父元素设置position relative,以及固定宽高
水平居中

    position:'absolute',
    top:-10,
    height: 40,
    marginLeft:-110,//值为width一半
    width:220,
    left:'50%',在这里插入代码片

水平居中垂直居中

    position:'absolute',
    top:-10,
    height: 40,
    marginLeft:-110,//值为width一半
    marginTop:-20,//值为height一半
    top:50%,
    width:220,
    left:'50%',在这里插入代码片
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐