五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > css教程:DIV垂直居中的辦法

css教程:DIV垂直居中的辦法

文章來源:365jz.com     點(diǎn)擊數(shù):183    更新時(shí)間:2009-05-17 23:05   參與評(píng)論

經(jīng)過今天一翻改進(jìn),終于找出了解決DIV垂直居中的辦法。

以下為引用的內(nèi)容:
<!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>CSS布局技巧:未知高度div 垂直居中的問題</title>
<style type="text/css">
html,body
{
  height: 100%;
  padding:0;
  margin:0;
}
body
{
  min-height: 200px;
  text-align: center;
  min-width: 402px
}
.FirstDIV
{
  margin-top: -100px; /* SecondDIV高度的一半  */
  float: left;
  width: 100%;
  height: 50%;
}
.SecondDIV
{
  clear: both;
  border: silver 1px solid;
  background: #666;
  margin-left: auto;
  overflow: auto;
  width: 400px;
  margin-right: auto;
  height: 200px;
  text-align: left
}
</style>
</head>
<body>
<div class="FirstDIV"></div>
<div class="SecondDIV">
    <p>看看,這不就居中了。呵呵。而且沒有問題哦。www.Webjx.com </p>
    <p>body{ background-color:#FFF5F0}<br>
        div{ position:absolute; top:50%; left:50%; margin:-100px 0 0 -200px;
            width:400px; height:200px; border:1px #CCCC00 solid; font-family:Arial,
            Helvetica, sans-serif; color:#666666 } </p>
</div>
</body>
</html>

如對(duì)本文有疑問,請(qǐng)?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會(huì)為你解答!! 點(diǎn)擊進(jìn)入論壇

發(fā)表評(píng)論 (183人查看0條評(píng)論)
請(qǐng)自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴(yán)禁發(fā)布色情、暴力、反動(dòng)的言論。
昵稱:
最新評(píng)論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學(xué)習(xí)

業(yè)務(wù)咨詢

· 技術(shù)支持
· 服務(wù)時(shí)間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號(hào)