当前位置:   article > 正文

flex布局文本居中,文本溢出自动换行的方法_flex 文字换行

flex 文字换行

直接上代码了

display:flex;
flex:1;
align-items: center;
justify-content: center;
overflow:hidden;
word-wrap:break-word;
word-break:break-all;
border-right:1px solid #323232;
font-size:12px;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="box">
      <div class="itemOne">
        <div class="itemOne1">
          动态内容XXXXX居中 50%动态内容XXXXX居中
          50%动态内容XXXXX居中50%0%动态内容XXXXX居中50% 0%动态内容XXXXX居中50%
          0%动态内容XXXXX居中50%
          0%动态内容XXXXX居中50%0%动态内容XXXXX居中50%0%动态内容XXXXX居中50%
        </div>
      </div>
      <div class="itemTwo">
        <div class="itemTwo1">头部33333333333333333333333333333</div>
        <div class="itemTwo3"></div>
        <div class="itemTwo1">底部</div>
      </div>
    </div>
    <script></script>
  </body>
</html>
<style>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  .box {
    width: 100%;
    height: 400px;
    background-color: plum;
    display: flex;
  }
  .itemOne {
    width: 75%;
    height: 100%;
    background-color: red;
    display: flex;
    justify-content: center;
  }
  .itemOne1 {
    width: 100%;
    height: 100%;
    background-color: rgb(192, 236, 255);
    margin-left: 33%;
    flex: 1;
    overflow: hidden;
    word-wrap: break-word;
    word-break: break-all;
    border-right: 1px solid #323232;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .itemTwo {
    width: 25%;
    height: 100%;
    background-color: green;
    display: flex;
    flex-direction: column;
    align-content: space-between;
    margin-left: 10px;
  }
  .itemTwo1 {
    width: 50%;
    height: 33%;
    background-color: yellow;
    flex: 1;
    overflow: hidden;
    word-wrap: break-word;
    word-break: break-all;
    border-right: 1px solid #323232;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .itemTwo3 {
    width: 50%;
    height: 33%;
  }
</style>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/235016?site
推荐阅读
相关标签
  

闽ICP备14008679号