Javascript 点击菜单

Javascript Onclick Menu

我使用了这个演示:

Drop down menu with on click toggle

要做到这一点:

http://jsfiddle.net/q0m4mk5o/

我唯一需要做的就是确保子菜单也水平显示。但是我对 CSS 的理解不够,无法让它发挥作用。另外,我创建这个是为了学习目的。

我觉得可能跟这个有点关系:

.testul li ul {
display: none;
list-style: none;
position: absolute;
left: 0;
}
.testul li ul li {
list-style: none;
white-space: nowrap;
height: 24px;
line-height: 24px;
background: -webkit-linear-gradient(#c8bfb0, #f5efe6);
border-bottom: 1px solid #d3c7b6;
}

只需将 display: inline-block 添加为:

JSFiddle

.testul li ul li {
    display: inline-block;
    list-style: none;
    white-space: nowrap;
    height: 24px;
    line-height: 24px;
    background: -webkit-linear-gradient(#c8bfb0, #f5efe6);
    border-bottom: 1px solid #d3c7b6;
}