css实现圆中居中显示文字

很久没更新博客了…趁做毕设的机会记录一下。

需求

画一个实心圆,并在圆中居中显示一行标题

实现思路

  1. 画圆:这里需要注意 border-radius:50%
  2. 居中显示文字:此处需要令 line-height 值等于 height ,并设置 text-align:center

代码

  1. html代码
  <view class="circle">
    <view class='circle-text'>
    {{chooseImg}}
    </view>
  </view>
  1. css代码
.circle{
  width: 360rpx;
  height: 360rpx;
  margin-top: 180rpx;
  border-radius: 50%;
  background-color: #1E90FF;
}

.circle-text{
  width: 360rpx;
  height: 360rpx;
  line-height: 360rpx;
  text-align: center;
  font-size: 56rpx;
  color: #ffffff;
}

效果

css实现圆中居中显示文字

猜你喜欢

转载自blog.csdn.net/Eggbeauty/article/details/83958852
今日推荐