云南網(wǎng)站建設(shè)創(chuàng)新企業(yè) 昆明多彩網(wǎng)絡(luò)公司

在線qq:540105663

div布局頁面無法居中的問題

來源:昆明多彩網(wǎng)絡(luò)公司 日期:2010-09-17 閱讀: 發(fā)表評(píng)論

在div布局中,都是使用margin:0 auto的css來是div居中,但是前提是需要使用xhtml標(biāo)準(zhǔn),如果沒有使用該標(biāo)準(zhǔn),div將無法居中

看看不能居中的代碼實(shí)例:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題文檔</title>
</head>
<body>
<div style="width: 1002px; height:100px; margin: 0 auto"><a href="http://www.dallashardmoneylender.com">昆明網(wǎng)站建設(shè)</a></div>
</body>
</html>
 

雖然將div定義了高度和寬度,并且設(shè)置了marign屬性,但是任然無法實(shí)現(xiàn)div居中,正確代碼應(yīng)該是:

<!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>無標(biāo)題文檔</title>
</head>
<body>
<div style="width: 1002px; height:100px; margin: 0 auto"><a href="http://www.dallashardmoneylender.com">昆明網(wǎng)站建設(shè)</a></div>
</body>
</html>

發(fā)表評(píng)論評(píng)論列表(有 條評(píng)論)

相關(guān)文章:
暫無相關(guān)文章
最熱文章:
新手怎么制作網(wǎng)頁? 閱讀:7660
jcarousellite中文文檔 閱讀:6507
表單元素input、按鈕、文字完美垂 閱讀:6247
怎么使chrome(谷歌google 閱讀:6145
phpMailer中文文檔手冊(cè) 閱讀:4639