zoukankan      html  css  js  c++  java
  • CSS:文字水平居中的写法

    <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-item.bc_green {
      width: 100px;
      height: 100px;
      background-color: green;
      text-align: center;
      line-height: 100px;
    }
    
    .flex-item.bc_red {
      width: 100px;
      height: 100px;
      background-color: red;
      text-align: center;
      line-height: 100px;
    }
    
    .flex-item.bc_blue {
      width: 100px;
      height: 100px;
      background-color: blue;
      text-align: center;
      line-height: 100px;
    }

     下面这种写法也是可以的:

    .flex-wrp {
      display: flex;
    }
    .flex-item{
      display: flex;
       width: 100px;
      height: 100px;
      justify-content: center;
      align-items: center;
    }
    
    .bc_green {
      background-color: green;
    }
    
    .flex-wrp .flex-item.bc_red {
      background-color: red;
    }
    
    .flex-wrp .flex-item.bc_blue {
      background-color: blue;
    }
  • 相关阅读:
    jquery笔记
    linux的日常经常使用的命令
    IDEA设置类注解和方法注解(详解)
    java读取项目或包下面的属性文件方法
    枚举类的使用
    将一个浮点数转化为人民币大写字符串
    简单五子棋实现
    crontab 设置服务器定期执行备份工作
    linux创建日期文件名
    代码层读写分离实现
  • 原文地址:https://www.cnblogs.com/herizai/p/8460719.html
Copyright © 2011-2022 走看看