为什么我的菜单偏离中心? [英] Why is my menu off-center?

查看:96
本文介绍了为什么我的菜单偏离中心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



http:/的演示页面/www.robschwimmer.com/tmp/test.html 底部有一个菜单位于

,左右两侧居中50个像素

边缘。正如封闭div周围的绿色虚线所示,它至少是* b $ b - 至少在Mozilla中 - 实际上是向右推的。


HTML和CSS验证很好(在CSS上有一些警告用

来处理颜色,但这是我故意设置文本的方式

颜色。)


不知道发生了什么事吗?


谢谢,


Pierre

-

Pierre Jelenc |内政部新闻:Ethan Lipton

| www.homeofficerecords.com www.ethanlipton.com

千分表|辣椒地球:HO博客
www.gigometer.com | www.homeofficerecords.com/blog

解决方案

Pierre Jelenc写道:

http://www.robschwimmer.com/tmp/test.html 在底部有一个菜单,它应该从左右两侧居中<边缘。由于围绕div的绿色虚线表示,它至少是Mozilla - 实际上是向右推的。




摆脱50px边距 - 左/右。


[...]


-

Rob


http://www.robschwimmer.com/tmp/test.html在底部有一个菜单,它应该从左右两侧边缘居中50个像素。由于围绕div的绿色虚线表示,它至少在Mozilla中 - 实际上被推向右边。

HTML和CSS都可以正常验证(有一些警告)在CSS上有关于颜色的问题,但这是故意设置文本颜色的方式。)

知道发生了什么事吗? br />
谢谢,

皮埃尔



有一种方法可以强迫div使用一些负面的

值,但我找不到参考。您要做的是

在Mozilla渲染器中不起作用。保证金权利将被忽略。您可以

妥协并选择:


" margin-left:50px;宽度:90%;


如果我在窗口中广泛使用,实际上看起来相当不错。另外,

考虑在

菜单的左侧和右侧添加两个固定大小的div。不是很优雅,但是诀窍


__ / [RobG]于2005年9月20日星期二05:52 \__


摆脱50px边距 - 左/右。

[...]




这似乎不是做伎俩 ;在Firefox中。

Roy


-

Roy S. Schestowitz | 释放思想,来源将遵循
http://Schestowitz.com | SuSE Linux | PGP-Key:74572E8E

7:35 am up 25 days 19:49,3位用户,平均负载:1.22,0.65,0.44


Pierre Jelenc写道:

http:/的演示页面/www.robschwimmer.com/tmp/test.html 底部有一个菜单,它应该位于距离左右边缘50像素的中心。由于围绕div的绿色虚线表示,它至少在Mozilla中 - 实际上是向右推的。




设置宽度规则低于100%,比如90%,并将左边的规则设置为一半

,比如说5%


这将按照你的意愿渲染Moz但IE不支持固定位置。


您可以通过使用绝对位置来获取浏览器的内容而不是

但是根据页面可能会导致其他问题长度。


Louise



The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.

Both HTML and CSS validate fine (there are some warnings on the CSS having
to do with color, but that''s deliberate for the way I set the text
colors.)

Any idea what''s happening?

Thanks,

Pierre
--
Pierre Jelenc | New on Home Office Records: Ethan Lipton
| www.homeofficerecords.com www.ethanlipton.com
The Gigometer | Pepper Of The Earth: the HO blog
www.gigometer.com | www.homeofficerecords.com/blog

解决方案

Pierre Jelenc wrote:

The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.



Get rid of the 50px margin-left/right.

[...]

--
Rob


__/ [Pierre Jelenc] on Tuesday 20 September 2005 00:30 \__


The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.

Both HTML and CSS validate fine (there are some warnings on the CSS having
to do with color, but that''s deliberate for the way I set the text
colors.)

Any idea what''s happening?

Thanks,

Pierre

There is a way of forcing divs to lie in the centre using some negative
values, but I could not find a reference. What you are trying to do will
not work in the Mozilla renderer. The margin-right will be ignored. You can
either compromise and go for:

"margin-left: 50px; width: 90%;"

which in practice looks quite OK if I reside the window quite widely. Also,
consider adding two fixed-sized divs to the left and the right of your
menu. Not elegant, but does the trick

__/ [RobG] on Tuesday 20 September 2005 05:52 \__

Get rid of the 50px margin-left/right.

[...]



This doesn''t appear to be "doing the trick" in Firefox.
Roy

--
Roy S. Schestowitz | "Free the mind, the source will follow"
http://Schestowitz.com | SuSE Linux | PGP-Key: 74572E8E
7:35am up 25 days 19:49, 3 users, load average: 1.22, 0.65, 0.44


Pierre Jelenc wrote:

The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.



Set width rule at less than 100%, say 90%, and set the left rule at half
of that, say 5%

This will render as you wish in Moz but IE does not honour position fixed.

You could get something cross browser by using position absolute instead
but this may result in other problems according to page length.

Louise


这篇关于为什么我的菜单偏离中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆