css - 按钮的悬停效果与 Logo 的一部分重叠

标签 css

enter image description here

编辑 更改了文本以更好地反射(reflect)问题。

对于现场演示,您可以在此处查看网站:http://wow-klickers.de/ (我修改了这里的CSS,可能会解决问题。)

所以我有以下场景。我的网站包含一个导航栏,在上图中包含一个“论坛”按钮,上面有一个 Logo 。如果我越过按钮,悬停效果会隐藏延伸到按钮中的 Logo 部分。我想将鼠标悬停在按钮上但不隐藏 Logo 部分。

这是我的代码片段:

<h1 id="logo"> // the blue box of the 2. picture
  <a href="/"></a> // the blue box of the 1. picture
</h1>

CSS 内容:

#logo a {
  width: 275px;
  height: 126px;
  display: block;
  position: relative;
  bottom: 18px; // added here
}

h1#logo {
  margin: 0;
  position: relative;
  left: 85px;
  top: 6px;
  background: url("images/logo.png") no-repeat;
  width: 275px;
  display: block;
  z-index: 2; // changed here
  height: 126px; // added here
}

#primary-menu-bar li a, #primary-menu-bar ul.menu li a {
  display: block;
  white-space: nowrap;
  height: 37px;
  line-height: 29px;
  position: relative;
  z-index: 1;
}

编辑 我尝试使用填充或边距,但使用边距我的 Logo 被切断,但 Logo 应该覆盖在按钮上。填充不起作用..

最佳答案

z-index:10添加到h1#logo,而不仅仅是在里面的a标签上。

关于css - 按钮的悬停效果与 Logo 的一部分重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17528175/

相关文章:

html - 扩展 :after inline-block for the rest of the element

jquery - Twitter Bootstrap Accordion 全高面板

html - 如何将图像和文本放置在它们的对齐方式随 HTML 中的浏览器窗口大小而变化的位置旁边?

jQuery:循环淡入淡出 + CSS 背景拉伸(stretch)

html - 我可以设置溢出: hidden but still show a scrollbar?吗

html - 使用 CSS 合并节标签的边框颜色

css - 修复网页上的表头

html - 在多个图像上居中文本

html - 如何从菜单项之间的填充中删除链接

jquery - 无法弄清楚如何在 KreatureMedia Layerslider 中循环播放 css 动画