CSS菜单栏文本问题

发布于 2024-11-25 01:29:45 字数 452 浏览 4 评论 0原文

我正在尝试创建一个菜单栏,其中包含一系列水平排列的图标和文本。我使用无序列表作为容器,但遇到问题。所有不包含文本、仅包含背景图像的空锚标记的菜单项都可以很好地内嵌显示。

但是,每当我尝试使用文本而不是背景图像作为菜单项时,文本列表项就会向下滑动。您可以在 JSFiddle 上看到此示例,请务必滚动每个项目以查看背景颜色指示器的行为:http ://jsfiddle.net/pAfgm/6/

请注意每个带有地球图标的链接(是的,在本例中我是从 Facebook 热链接的)如何显示得漂亮而整洁。然而,文本和它的背景指示符远远偏离对齐。我发现 FF 3.6、Opera 11 是这样,但 IE7 不是这样!这一次,IE7 不再出现其他浏览器存在的问题。

有人可以告诉我如何纠正这个问题吗?

谢谢您的宝贵时间!

I am trying to create a menu bar which will consist of a series of icons and text laid out horizontally. I am using an unordered list as the container, but I am having a problem. All of the menu items which contain no text, just an empty anchor tag with a background image, display in-line just fine.

However, whenever I try to use text, instead of a background image as a menu item, the text list item is slid downward. You can see this example on JSFiddle, be sure to rollover each of the items to see how the background color indicator behaves: http://jsfiddle.net/pAfgm/6/.

Notice how each of the links with a globe icon (yes, I hot-linked from Facebook for this example) displays nice and neat. However the text and it's background indicator are way off alignment. I see this is the case for FF 3.6, Opera 11, but not IE7! For once, IE7 isn't having a problem where other browsers are.

Could someone please show me how I can correct this issue?

Thank you for your time!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不吻晚风 2024-12-02 01:29:45

您只需将 vertical-align: top 添加到 nav.pluginBar ul.pluginBarLeft li 中,并在其上添加 display: inline-block

参见: http://jsfiddle.net/pAfgm/7/

默认的vertical-align值为baseline,这就是导致此问题的原因。

请在此处查看不同 vertical-align 值之间的差异:
http://www.brunildo.org/test/inline-block.html

请参阅此处的“基线”部分以获得图形解释:
http://blog.mozilla.com/webdev/ 2009/02/20/跨浏览器内联块/

You simply need to add vertical-align: top to nav.pluginBar ul.pluginBarLeft li, on which you also have display: inline-block.

See: http://jsfiddle.net/pAfgm/7/

The default vertical-align value is baseline, which is the cause of this problem.

See the difference between different vertical-align values here:
http://www.brunildo.org/test/inline-block.html

See the "baseline" section here for a graphical explanation:
http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文