zoukankan      html  css  js  c++  java
  • 完美解决固定容器高度,文字内容一行或多行,文字上下居中,解决兼容性

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    <html xmlns="http://www.w3.org/1999/xhtml">   
      <head>   
        <title> 多行文字实现垂直居中 </title>   
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
        <style type="text/css">   
          body { font-size:12px;font-family:tahoma;}   
          div#wrap {   
            display:table;   
            border:1px solid #FF0099;   
            background-color:#FFCCFF;   
            760px;   
            height:400px;   
            *position:relative;   
            overflow:hidden;   
          }   
          div#subwrap {   
            vertical-align:middle;   
            display:table-cell;   
            *position:absolute;   
            *top:50%;   
          }   
          div#content {   
            *position:relative;   
            *top:-50%;   
          }   
        </style>   
      </head>   
      <body>   
        <div id="wrap">   
          <div id="subwrap">   
            <div id="content"><pre>现在我们要使这段文字垂直居中显示!   
              div#wrap {   
                border:1px solid #FF0099;   
                background-color:#FFCCFF;   
                760px;   
                height:500px;   
                position:relative;   
              }   
              div#subwrap {   
                position:absolute;   
                border:1px solid #000;   
                top:50%;   
              }   
              div#content {   
                border:1px solid #000;   
                position:relative;   
                top:-50%;   
              }  
            </pre></div>   
          </div>   
        </div>   
      </body>   
    </html>

  • 相关阅读:
    JavaScript知识点总结
    Python错误:ImportError: No module named 'requests'
    The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class
    Html重点知识
    使用Gson中的JsonElement所遇到的坑
    AndroidStudio:The number of method references in a .dex file cannot exceed 64K错误
    使用TextUtils.isEmpty()遇到的坑
    Gson常用方法
    AndroidStudio——java.lang.UnsatisfiedLinkError错误
    RecyclerView点击,移动到中间位置
  • 原文地址:https://www.cnblogs.com/liujinyu/p/3633713.html
Copyright © 2011-2022 走看看