| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 959 人关注过本帖
标题:习惯了这里,问个div+css绝对居中的问题!!!
只看楼主 加入收藏
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
 问题点数:0 回复次数:5 
习惯了这里,问个div+css绝对居中的问题!!!
div+css绝对居中问题!!请不吝赐教!!
index.html代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Pink Doll</title>
<LINK
href="css.css" type=text/css rel=stylesheet>
</head>

<body>
<div id="dw">
<div class="aa">aaa</div>
<div class="bb">aaa</div>
<div class="cc">aaa</div>
</div>

</body>
</html>

css.css代码:
#dw
{
width: 300px;
height: 200px;
margin-top:0px ;
margin-left :0px;
margin-bottom :0px;
margin-right:0px;
}
.aa
{
margin-top:0px ;
margin-left :0px;
width: 100px;
height: 200px;
background-color: #000000;
}

.bb
{
margin-top:-200px ;
margin-left :100px;
width: 100px;
height: 200px;
background-color: #999999;
}

.cc
{
margin-top:-200px ;
margin-left :200px;
width: 100px;
height: 200px;
background-color: #666666;
}

可不能绝对居中,不知道为什么?请知道的指教!!
退一步,就算不能绝对居中,能居中就好!!!
但谁要是知道绝对居中那是最好!!!

程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Pink Doll</title>
<LINK 
href="css.css" type=text/css rel=stylesheet>
</head>

<body>
<div id="dww">
<div id="dw">
<div class="aa">aaa</div>
<div class="bb">aaa</div>
<div class="cc">aaa</div>
</div>
</div>
</body>
</html>


[[it] 本帖最后由 xinzheng 于 2008-6-12 19:17 编辑 [/it]]
搜索更多相关主题的帖子: div css 习惯 Pink index 
2008-06-12 18:06
xiapi
Rank: 1
等 级:新手上路
威 望:2
帖 子:305
专家分:0
注 册:2006-10-11
收藏
得分:0 
<div align=center>或者css里加入text-align:center

没有什么能够阻挡,我对自由的向往,天马行空的生涯一颗心了无牵挂。
2008-06-12 18:25
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
得分:0 
我的意思是要<div id="dw"></div>绝对居中
2008-06-12 19:16
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
得分:0 
我找到了,晕
#dw-index
{
background:url('bg-1.jpg') no-repeat;
width: 400px;
height: 400px;
position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -200px;
  margin-top: -200px;
}

居中是居中了,可背景不知道跑哪去了?

[[it] 本帖最后由 xinzheng 于 2008-6-12 20:25 编辑 [/it]]
2008-06-12 19:47
天涯听雨
Rank: 2
来 自:东莞
等 级:论坛游民
威 望:4
帖 子:497
专家分:64
注 册:2007-8-25
收藏
得分:0 
Css 里加:

body{text-align:center;}     'body 里的元某都绝对居中

从明天起做幸福的人,喂马劈柴周游世界!
2008-06-12 21:00
dhdhzzw
Rank: 1
等 级:新手上路
帖 子:949
专家分:0
注 册:2007-8-13
收藏
得分:0 
[bo][un]xinzheng[/un] 在 2008-6-12 19:47 的发言:[/bo]

我找到了,晕
#dw-index
{
background:url('bg-1.jpg') no-repeat;
width: 400px;
height: 400px;
position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -200px;
  margin-top: -200px;
}

居 ...


============
在这一句后面,加   background:url('bg-1.jpg') no-repeat center center;
2008-06-13 09:31
快速回复:习惯了这里,问个div+css绝对居中的问题!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018037 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved