国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > CSS > 正文

CSS圖片垂直居中方法整理集合

2024-07-11 08:20:12
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

一、基本方法:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
<!--
* {margin:0;padding:0}
div {
   width:500px;
   height:500px;
   border:1px solid #ccc;
   overflow:hidden;
   position:relative;
   display:table-cell;
   text-align:center;
   vertical-align:middle
   }
div p {
   position:static;
   +position:absolute;
   top:50%
   }
img {
   position:static;
   +position:relative;
   top:-50%;left:-50%;
   width:276px;
   height:110px
   }

-->
</style>

<div><p><img src="

二、標(biāo)準(zhǔn)瀏覽器下另類方法:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
<!--
body {
    margin:0;padding:0
    }
div {
    width:500px;
    height:500px;
    line-height:500px;
    border:1px solid #ccc;
    overflow:hidden;
    position:relative;
    text-align:center;
    margin:auto
    }
div p {
    position:static;
    +position:absolute;
    top:50%
    }
img {
    position:static;
    +position:relative;
    top:-50%;left:-50%;
    width:276px;
    height:110px;
    vertical-align:middle
    }
p:after {
    content:".";font-size:1px;
    visibility:hidden
    }
-->
</style>

<div><p><img src="<A href='/uploadfiles/2008/03131204580.gif"/></p></div>


三、標(biāo)準(zhǔn)瀏覽器嚴(yán)格型申明下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<style type="text/css">
<!--
* {margin:0;padding:0}
div {
    width:500px;
    height:500px;
    line-height:500px;
    border:1px solid #ccc;
    overflow:hidden;
    position:relative;
    text-align:center;
    }
div p {
    position:static;
    +position:absolute;
    top:50%;
    vertical-align:middle
    }
img {
    position:static;
    +position:relative;
    top:-50%;left:-50%;
    width:276px;
    height:110px;
    vertical-align:middle
    }

-->
</style>

<div><p><img src="


四、利用字體大小的方法:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<style type="text/css">
* {margin:0;padding:0;}
div {
    width:500px;text-align:center;border:1px solid #f00;line-height:500px;
    height:500px;font-size:500px
    }
*>div{
    font-size:12px
    }
div img {
    vertical-align:middle
    }
</style>

<div>
<img src="</div>

五、最簡(jiǎn)單當(dāng)然是背景圖片的方法啦
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<style type="text/css">
* {margin:0;padding:0;}
div {
    width:500px;border:1px solid #f00;
    height:500px;
    background:url("    }
</style>

<div>
</div>

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 衡东县| 昆明市| 营口市| 泾川县| 青川县| 连平县| 县级市| 娄底市| 西丰县| 徐汇区| 卢氏县| 松溪县| 宜宾县| 鄂州市| 荥阳市| 瓦房店市| 牡丹江市| 巴林右旗| 洛扎县| 通辽市| 罗田县| 札达县| 盘山县| 东阳市| 大安市| 亚东县| 博乐市| 琼中| 南平市| 安义县| 来安县| 永新县| 呼伦贝尔市| 新泰市| 黔江区| 秀山| 页游| 青阳县| 雷波县| 巴中市| 开阳县|