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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>phone center</title>
    <style type="text/css">
    
    .box{
    100px;
    height:100px;
    border:1px solid #ccc;
    text-align:center;
    border:1px solid #ccc;
    }
    .box img{
    vertical-align:middle;
    max-100%;
    }
    .box span{
    display:inline-block;
    height:100%;
    0px;
    overflow:hidden;
    vertical-align:middle;    
    background:red;
    }
    </style>
    </head>
    
    <body>
    <div class="box">
    <img src="ceshi/images/head-img.png" /><span></span>
    </div>
    </body>
    </html>
    
    
     
    
     
    
     
    
     
    
    方法二:
    
     
    
     
    
    <!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=utf-8" />
    <title>phone center</title>
    <style type="text/css">
    .box{
    100px;
    height:100px;
    display:table-cell;
    text-align:center;
    vertical-align:middle;
    border:1px solid #ccc;
    }
    </style>
    </head>
    
     
    
    <body>
    <div class="box">
    <img src="ceshi/images/head-img.png" />
    </div>
    </body>
    </html>
    
     方法三:
    
    <style>
    
    #box{500px;height:500px;position:relative;}
    #box img{100px;height:100px;position:absolute;top:50%;left:50%;margin-top:-50px;margin-left:-50px}
    </style>
    <div id="box">
    <img src="xxx.jpg">
    </div>
     
  • 相关阅读:
    基于jQuery的一个弹出层
    获取一个数组内的最大最小值
    flex内根据id(string)获取对象
    整理的一份iframe编辑器代码
    仿163邮箱工具条
    获取dom到浏览器窗口坐上坐标
    the solution to fix 'Failed to access IIS metabase'
    .Net下的Windows服务程序开发指南.
    Castle学习笔记之Windsor(二)
    IOC:主要概念
  • 原文地址:https://www.cnblogs.com/jinsuo/p/5937966.html
Copyright © 2011-2022 走看看