下拉菜单CSS3的位置 [英] Drop down menu CSS3 position

查看:224
本文介绍了下拉菜单CSS3的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果将鼠标悬停在User菜单上,则菜单会显示在左侧=0.但是,它应该恰好显示在User按钮"下方.我该怎么做? (仅CSS3)

If you hover over the User menu, then the menu shows up at left = 0. But, it should show up exactly under the User 'button'. How can I accomplish this? (only CSS3)

推荐答案

将此规则添加到CSS:

Add this rule to your CSS:

.menu > li {
    position: relative;
}

说明::如果在元素上指定position: absolute,则topleft将相对于具有除static以外的任何position的第一个父元素.如果找不到类似的元素,则它将相对于页面(如您的情况).指定position: relative是最简单的解决方案,因为该元素不会从文档流中删除.

Explanation: if you specify position: absolute on an element, top and left will be relative to the first parent element that has any position other than static. If no element like that is found, it will be relative to the page (like in your case). Specifying position: relative is the easiest solution because the element won't be taken out of the document flow.

这篇关于下拉菜单CSS3的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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