1
gucheen 2012 年 7 月 31 日
你logo和front都没有给剧中啊。。。
|
4
gucheen 2012 年 7 月 31 日
然后加上margin:auto;我这边是可以居中的
|
5
NemoAlex 2012 年 7 月 31 日
CSS 里有几个多余的 “}”
|
6
zsdsz 2012 年 7 月 31 日
你body设置了宽度,logo是相对于body居中的,你删掉body的宽度就知道。
|
7
stackpop OP @gucheen 我删除了那2个多余的} 加了margin:auto依然没有效果。。。。
*{ padding: 0; margin: 0; } body{ width: 800px; background: url(bg2.jpg); } img{ border: 0; } .main{ margin: auto; width:730px; } .logo{ width:428; height: 285px; background: url(logo.png) no-repeat; margin: auto; } #front{ margin: auto; height: 285px; background: url(logo.png) no-repeat; } .startgame{ margin-top: 100px; padding-bottom: 100px; } .startgame a:hover { background: url(bta.png) no-repeat 0px -313px; } .startgame a { width: 163px; height: 45px; display: block; background: url(bta.png) no-repeat 0px -223px; margin:auto; } |
9
gucheen 2012 年 7 月 31 日
我这边一切正常,话说你把logo的width的px加上,我用border代替图片,显示是居中的
|
11
luin 2012 年 7 月 31 日
.logo 的 width 你没加 px
|
12
lingyired 2012 年 7 月 31 日
width:428;
|
14
frittle 2012 年 7 月 31 日
除了上面指出的错误之外,在IE里是无法用margin: auto来居中的。
|
16
cloudhunter 2012 年 7 月 31 日
在IE上想用margin: 0 auto;来居中,必须指定正确的html头部声明如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
17
wuxiaolin 2012 年 8 月 2 日
好长的代码
|
18
LcaKen0day 2012 年 8 月 2 日 你可以试试在这个div中加入一个<table border="0px" align="center" valign="center"></table>
|
19
LcaKen0day 2012 年 8 月 2 日
一般的话用div+css控制图片只可以水平剧终,控制不了垂直剧终 ,你可以试试在其中插入一个<table></table>利用table的属性去定义logo让其居中。
|
20
LcaKen0day 2012 年 8 月 2 日
还有就是注意一下类选择器跟id选择器是否有冲突,id选择器的优先级要高于类选择器。
|
21
Air_Mu 2012 年 8 月 2 日
这不是PHP问题
#front会覆盖.logo 你这样写没意义 给div.main设置宽度 不要给body设置。 |
22
VeryCB 2012 年 8 月 2 日 @LcaKen0day 额…现在都不提倡用div来布局了,table就更算了吧…
|
23
LcaKen0day 2012 年 8 月 2 日
@VeryCB 嗯 是很少了,不过这只是布局的一个方法而已。而且楼主貌似帖子发错地方了
|
24
wegottago2 2012 年 8 月 2 日
@stackpop body{text-align: center;}
|
25
wegottago2 2012 年 8 月 2 日
@stackpop wrapper{margin: auto;width: xxxpx;}
|
26
wegottago2 2012 年 8 月 2 日
@stackpop #wrapper{margin: auto;width: xxxpx;}
|
27
luguozmy 2012 年 8 月 3 日
|
28
j 2012 年 8 月 3 日
这个问题很简单,对于一个正常的浏览器来说,看到你给body设置了宽度,一定会让整个网页(body)以这个宽度居左对齐去了.你在后面对DIV做什么居中操作也只会让这个div相对body居中,而无法相对浏览器窗口居中.
|
29
m4ji 2012 年 8 月 3 日
我也搭车 问个问题.
http://10years.sinaapp.com/ css3 里可以把 盒模型 改成ie6形式的.所以,我试图以后都用ie6的盒子了. 但是用这两个 div 测试的时候.却发现了.问题. 一个加了padding, 一个没加padding.按理说, 我切换了盒模型之后.新款浏览器 显示的是等宽,这个我不难理解,本该如此. 但是,为什么我用ie6测试一下.却发现,ie6 里面 竟然是 正常的盒子的. 上下两个是 不等宽的. 如果不用 <!DOCTYPE html> 这个头的话, ie6 又会变成 原本的ie6盒子了. 是我的ie6被人打了补丁了吗?? 求大神验证下,你们的两个框框 是一样宽的么? 怎么理解这灵异 |
31
LcaKen0day 2012 年 8 月 3 日
@luguozmy web2.0主要是div+css
php+mysql |