zoukankan      html  css  js  c++  java
  • [收藏]DIV中图片居中

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>一个div里面图片垂直居中的例子</title>
    <style type="text/css">
    <!--
    div 
    {
    width
    :120px;
    height
    :100px;
    border
    :1px solid #ccc;
    overflow
    :hidden;
    position
    :relative;
    display
    :table-cell;
    text-align
    :center;
    vertical-align
    :middle;
    background-color
    :blue;
    }

    div span 
    {
    position
    :static;
    +position
    :absolute;
    top
    :50%;
    }

    img 
    {
    position
    :static;
    +position
    :relative;
    top
    :-50%;left:-50%;
    }

    -->
    </style>
    </head>

    <body>
        
    <div>
            
    <span>
                
    <img src=http://images.sohu.com/uiue/sohu_logo/beijing2008/sohu.gif>
            
    </span>
        
    </div>
    </body>
    </html>
    QQ:273352165 evlon#126.com 转载请注明出处。
  • 相关阅读:
    javaee 第六周作业
    javaee 第五周作业
    javaee 第四周作业
    第三周作业
    第二周作业xml学习情况
    javaWeb 中http请求 get 与 post的区别
    第八周
    第七周
    第六周
    第五周
  • 原文地址:https://www.cnblogs.com/evlon/p/684040.html
Copyright © 2011-2022 走看看