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>
     
  • 相关阅读:
    Cocos Creator 使用protobufjs
    Java操作MongoDB:连接&增&删&改&查
    MongoDB 权限控制
    SpringBoot 文件上传、下载、设置大小
    Java HashMap 遍历、删除、排序
    Java分割字符串
    在Windows下解决git ERROR: Permission to XXX.git denied to user
    阿里云域名+github建立网站
    Creazy Ideas 智能汽车和智能交通
    Windows上安装运行Hadoop
  • 原文地址:https://www.cnblogs.com/jinsuo/p/5937966.html
Copyright © 2011-2022 走看看