zoukankan      html  css  js  c++  java
  • CSS特效(7)——单行居中,多行居左,超过两行用省略号

    单行居中,多行居左,超过两行用省略号

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <style>
        * {
          margin: 0;
          padding: 0;
        }
    
        h2 em {
          position: relative;
          font-style: normal;
          text-align: left;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
    
        .container {
           320px;
          padding: 0 10px;
          margin: 10px auto;
          background: #ddd;
        }
    
        .container p {
          display: inline-block;
          text-align: center;
        }
    
        h2 {
          text-align: center;
          padding: 10px 0;
        }
      </style>
    </head>
    
    <body>
      <div class="container">
        <h2>
          <p>
            <em>我是单行标题居中</em>
          </p>
        </h2>
        <h2>
          <p>
            <em>我是两行标题两行标题两行标题居左</em>
          </p>
        </h2>
        <h2>
          <p>
            <em>我是超过两行的标题最后点号省略我是超过两行的标题最后点号省略我是超过两行的标题最后点号省略省略省略</em>
          </p>
        </h2>
      </div>
    </body>
    
    </html>
    
  • 相关阅读:
    check datagurad scripts using python
    nagios check_oracle plugin (add check temp tablespace)
    monitor tomcat sctips
    ATM 练习
    socket 练习 ftp
    socket 练习 sendcommand
    带你走进虚拟化世界之kvm(转载)
    luogu2732商店购物
    uva1625颜色的长度
    luogu3147 [USACO16OPEN]262144
  • 原文地址:https://www.cnblogs.com/janas-luo/p/9604834.html
Copyright © 2011-2022 走看看