滑动门 CSS 菜单问题...

发布于 2024-10-06 21:45:58 字数 411 浏览 0 评论 0原文

所以我正在尝试做一个滑动门 CSS 菜单——基本上是一张图像,当它悬停或处于活动状态时,您可以在其上移动背景位置。

但是,通常当我使用以下方法移动到下一个链接时:

#xmenu li.ypart {width:80px; height:35px;}
#xmenu li.ypart a {background-position:-33px 0px; }

它从最后一个链接到我指定的任何宽度。看到下图中的地图图标了吗?我正在尝试链接它,以便该链接不会一直从“发送反馈”链接到地图按钮。我只是希望链接是那个正方形。

https://i.sstatic.net/6S70f.png

有什么想法吗?

So I'm trying to do a sliding door CSS menu -- basically one image that you move the background position on when it's hovered or when it's active.

However, usually when I move to the next link using:

#xmenu li.ypart {width:80px; height:35px;}
#xmenu li.ypart a {background-position:-33px 0px; }

It takes from the last link to whatever width I specify. See the MAP icon on the image below? I'm trying to link it so that the link doesn't go all the way from the SEND FEEDBACK link to the map button. I just want the link to be that square.

https://i.sstatic.net/6S70f.png

So any ideas?

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

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

发布评论

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

评论(1

锦欢 2024-10-13 21:45:58

如果我理解正确,您应该将链接( 元素)设置为块元素,并为其指定特定的宽度和高度(可能还包括相对/绝对定位,具体取决于您的布局方式)设置)。这样,链接的点击区域将被限制在这些尺寸内。

标记是这样的:

...
<a href="/map">Map</a>
...

CSS 也是这样:

#xmenu li.ypart a { display: block; width: 40px; height: 35px; }

If I understand correctly, you should make the link (the <a> element) a block element and give it a specific width and height (and maybe relative/absolute positioning, depending on how your layout is set up). That way, the hit area for the link will be confined to those dimensions.

Something like this for the markup:

...
<a href="/map">Map</a>
...

And something like this for the CSS:

#xmenu li.ypart a { display: block; width: 40px; height: 35px; }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文