0

我有一个代码 HTML 代码:

<div class="wrapper-demo">

 <div id="dd" class="wrapper-dropdown-2" tabindex="1">Sign in with
                    <ul class="dropdown">
                        <li><a href="#"><i class="icon-twitter icon-large"></i>Twitter</a></li>
                        <li><a href="#"><i class="icon-github icon-large"></i>Github</a></li>
                        <li><a href="#"><i class="icon-facebook icon-large"></i>Facebook</a></li>
                    </ul>
                </div>
            </div>

和 CSS:

.wrapper-dropdown-2 {
position: relative; 
width: 200px;
margin: 0 auto;
padding: 10px 15px;

background: #fff;
border-left: 5px solid orange;
cursor: pointer;
text-align: left;
cursor: pointer;
outline: none;

}

.wrapper-dropdown-2:after {
    content: "";
    width: 0;
    height: 0;
    position: absolute;
    right: 16px;
    top: 50%;
    margin-top: -3px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: grey transparent;

}
.dropdown {
    display:none;
}
.wrapper-dropdown-2:hover ul.dropdown  {
    position: absolute;
    display:block;
    top: 100%;
    left: -5px;
    right: 0px;
    background: white;
    -webkit-transition: all 0.3s ease-out;
    -moz-transition: all 0.3s ease-out;
    -ms-transition: all 0.3s ease-out;
    -o-transition: all 0.3s ease-out;
    transition: all 0.3s ease-out;
    list-style: none;
    opacity: 0;
    pointer-events: none;
}
.wrapper-dropdown-2 .dropdown li a {
    display: block;
    text-decoration: none;
    color: #333;
    border-left: 5px solid;
    padding: 10px;
    -webkit-transition: all 0.3s ease-out;
    -moz-transition: all 0.3s ease-out;
    -ms-transition: all 0.3s ease-out;
    -o-transition: all 0.3s ease-out;
    transition: all 0.3s ease-out;
}

http://jsfiddle.net/pvt3e/

我尝试,将鼠标悬停在:通过打开下拉菜单登录,但它不起作用!我无法使用 js。因为我的1.8.2有问题,但是我觉得我们可以用CSS找到解决办法

4

4 回答 4

2

尝试这个

.wrapper-dropdown-2:hover ul{
    display:block;  
}

更新了 jsFiddle 文件

还从您的样式中删除 .dropdown:hover

于 2013-09-04T09:32:59.340 回答
1

您缺少添加悬停代码以在悬停时查看下拉菜单。为悬停添加 css。

.wrapper-dropdown-2:hover .dropdown
{
    display:block;
}

现场演示

于 2013-09-04T09:26:55.877 回答
0

只需替换你的这个 CSS

.dropdown:hover  {
  /* Size & position */
    position: absolute;
    display:block;
    top: 100%;
    left: -5px;
    right: 0px;

    /* Styles */
    background: white;
    -webkit-transition: all 0.3s ease-out;
    -moz-transition: all 0.3s ease-out;
    -ms-transition: all 0.3s ease-out;
    -o-transition: all 0.3s ease-out;
    transition: all 0.3s ease-out;
    list-style: none;

    /* Hiding */
    opacity: 0;
    pointer-events: none;
}

到我的 CSS 并获取结果

.wrapper-dropdown-2:hover > .dropdown  {
   position: absolute;
    display:block;
    left: -45px;
       background: white;
      top:24px;
 }
于 2013-09-04T09:34:45.260 回答
0

您将需要初始化您的 javascript 以及指向 jquery 的链接。我看到您正在使用 Codrops 的下拉菜单,为什么不直接下载源代码?

于 2013-09-04T09:26:34.723 回答