居中

2020-09-25  本文已影响0人  小北呀_
<template>
  <div>
    <div class="center">
      <div class="centerBox">
        <!-- 缺点:当内容宽度大于centerBox宽度的50%时就会折行 -->
        <div class="centerCont centerIcon">+</div>
        <div class="centerCont">上传图片</div>
      </div>
    </div>
  </div>
</template>
<style scoped>
.center{
  width: 400px;
  height: 40px;
  line-height: 40px;
  border: 1px solid pink;
  position: relative;
}
.centerBox{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}
.centerCont{
  float: left;
}
.centerIcon{
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 50%;
  border: 1px solid rgba(74,144,226,.5);
  font-size: 22px;
  color: #4A90E2;
  margin-top: 7px;
  margin-right: 8px;
}
</style>


如下图:


微信图片_20200925202215.png
上一篇 下一篇

猜你喜欢

热点阅读