CSS 行内元素设置高度

设置line-height属性
行内元素设置高度,并且文本垂直水平居中

    span {
      background: red;
      line-height: 100px;
      align-items: center;
      display: flex;
      justify-content: center;
    }
    span {
      background: red;
      line-height: 100px;
      align-items: center;
      display: inline-flex; /*宽度是文本宽度*/
      justify-content: center;
    }
    span {
      background: red;
      line-height: 100px;
      text-align: center;
      display: block;
    }
    span {
      background: red;
      line-height: 100px;
      text-align: center;
      display: inline-block;/*宽度是文本宽度*/
    }
    span {
      background: red;
      line-height: 100px;
      text-align: center;
      /*position: relative;*/
      /*position: fixed;*/
      position: absolute; /*会改变display为block,宽度是文本宽度*/
    }
    span {
      background: red;
      line-height: 100px;
      text-align: center;
      /*float: right;*/
      float: left;  /*会改变display为block,宽度是文本宽度*/
    
      
    }

你可能感兴趣的:(CSS)