zoukankan      html  css  js  c++  java
  • 常用html设置:

    • 省略
    • 居中

    1. 省略 ellipsis:  

      text-overflow:ellipsis;

           要求容器必须是固定的,要不然无法做省略。

           table的省略

    table{
     table_layout:fixed;  //默认是auto即根据内容大小自动扩充
    }
    table tr td,table tr th{
          white-space:nowrap;  // 不允许折行
          overflow:hidden;
          text-overflow:ellipsis;  
    }

           div的省略

    div{
       width:50px;
       text-overflow:ellipsis;
       overflow:hidden;
    }

    2.居中:

    .div{
      display:flex;
      align-items:center;
    }

       flex为html5内容,低版本ie不支持。

    可使用下面table属性代替居中:

    .cell{
        display: table-cell;
        vertical-align:middle;
        text-align:center;
    }
    
     .table{
        display: table;
        100%;
        height:80px;
     }
    <div class="table">
        <div class="cell">1</div>
    </div>

     还可用line-height:

    .cell{
        display: table-cell;
        vertical-align:middle;
        text-align:center;
    }
    
     .table{
        display: inline-table;
        60%;
        height:80px;
        line-height:80px;
     }
    
    </style>
    <div class="table">
        <div class="cell">1</div>
    </div>

     还可用margin-top:

    这种需要知道父元素的高度和子元素的高度。margin-top = 父元素高度/2 - 子元素高度/2

    .cell{
        30px;
        height:20px;
        background-color: #33f65c;
        margin: auto;
        margin-top:30px;
    }
    
     .table{
        display: block;
        60%;
        height:80px;
        text-align:center;
        background-color: #d3f3ac;
        overflow:hidden;
     }
    
    <div class="table">
        <div class="cell">1</div>
    </div>
  • 相关阅读:
    word文档的图片怎么保存到Web编辑器上
    如何在linux下查看gpu信息

    lua注释
    readDouble
    ..在lua中运用
    C++条件分支结构
    C++条件分支结构
    Flink基础(十六):Table API 和 Flink SQL(一)整体介绍
    Flink基础(十四):DS简介(14) 搭建Flink运行流式应用
  • 原文地址:https://www.cnblogs.com/DennyZhao/p/8418915.html
Copyright © 2011-2022 走看看