首页 > Web开发 > 详细

CSS:文字水平居中的写法

时间:2018-02-23 10:08:45      阅读:169      评论:0      收藏:0      [点我收藏+]
<view class=‘kk‘>
水平垂直居中文字
</view>
.kk{
  border: 1px solid #000000; 
  width: 200px; 
  height: 200px;
  margin: 0 auto;
  text-align: center;
  line-height: 200px;
}

其中line-height需要注意下。

 

<view class="section">
  <view class="section__title">flex-direction: row</view>
  <view class="flex-wrp" style="flex-direction:row;">
    <view class="flex-item bc_green">1</view>
    <view class="flex-item bc_red">2</view>
    <view class="flex-item bc_blue">3</view>
  </view>
</view>
<view class="section">
  <view class="section__title">flex-direction: column</view>
  <view class="flex-wrp" style="height: 300px;flex-direction:column;">
    <view class="flex-item bc_green">1</view>
    <view class="flex-item bc_red">2</view>
    <view class="flex-item bc_blue">3</view>
  </view>
</view>

 

.flex-wrp {
  display: flex;
}

.flex-wrp .flex-item.bc_green {
  width: 100px;
  height: 100px;
  line-height: 100px;
  background-color: green;
}

.flex-wrp .flex-item.bc_red {
  width: 100px;
  height: 100px;
  background-color: red;
  text-align: center;
  line-height: 100px;
}

.flex-wrp .flex-item.bc_blue {
  width: 100px;
  height: 100px;
  background-color: blue;
  text-align: center;
  line-height: 100px;
}

技术分享图片

 

CSS:文字水平居中的写法

原文:https://www.cnblogs.com/herizai/p/8460719.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!