0

かなりまともなメニューだと思う素晴らしいチュートリアルを見つけました。http://nettuts.s3.amazonaws.com/699_nav/navCode/nav.htmlまたはhttp://net.tutsplus.com/tutorials/html-cssのような垂直ドロップダウンに変換しようとしています。-techniques/how-to-build-a-kick-butt-css3-mega-drop-down-menu/?search_index=3

リストを横からではなくドロップダウンさせたいだけです。私はそれを解決すると思ったことを試し、li要素をターゲットにしてインラインで表示するなどしましたが、変更しても効果がないか、ごちゃごちゃした混乱を引き起こします。

フィドル

CSS

#thisNav{
    width: 250px;
    margin: 20px;
    background:#bada55;
}

#thisNav ul{
    list-style: none;
    margin: 0;
    padding: 0;
}

#thisNav ul li{
    /*child elements positioned absolutley will be relative to this*/
    position: relative;
    border-top: 1px solid #e9e9e9;

}

#thisNav a{
    color: ghostwhite;
    padding: 12px 0px;
    /*fill hori space*/
    display: block;
    text-decoration: none;
/*apply transition to background property, taking 1s to change it
*/
    transition:padding 1s, background 1s;
    -moz-transition:padding 1s, background 1s;
    -webkit-transition:padding 1s, background 1s;
    -o-transition:padding 1s, background 1s;

    font-family:tahoma;

    font-size:13px;
    text-transform:uppercase;
    padding-left:20px;
}

/*hover pseduo class*/
#thisNav a:hover{
    /*
    RGBA background for transparancy:
    last number(0.05) is the transparency
    */
    padding-left:35px;
    background: RGBA(255,255,255,0.05);
    color:#fff;
}

#thisNav ul li:hover ul{
    /*diplay when hovered*/
    display: block;

}

#thisNav ul ul{
    position: absolute;
    left: 250px;
    top: 0;
    border-top: 1px solid #e9e9e9;
    display: none;
    width: 304px;
}

#thisNav ul ul li{
    width: 150px;
    background: #f1f1f1;
    border: 1px solid #e9e9e9;
    border-top: 0;
    float:left;

}

#thisNav ul ul li a{
    color:#000000;
    font-size:12px;
    text-transform:none;
}

#thisNav ul ul li a:hover {
    color:#929292;
}

#thisNav span {
    width:12px;
    height:12px;
    background:#fff;
    display:inline-block;
    float:left;
    margin-top:3px;
    margin-right:10px;
    position:relative;
    transition:all 0.5s;
    -moz-transition:all 0.5s;
    -o-transition:all 0.5s;
    -webkit-transition:all 0.5s;
}
#thisNav a:hover span {
    background: #7d2c41;
    transform:rotate(90deg);
    -moz-transform:rotate(90deg);
    -webkit-transform:rotate(90deg);
}

/*Horizontal line*/
#thisNav span:before {
    content:"";
    width:12px;
    height:2px;
    background:#3a3b3b;
    position:absolute;
    left:0px;
    top:5px;
}
/*Vertical line*/
#thisNav span:after {
    content:"";
    width:2px;
    height:12px;
    background:#3a3b3b;
    position:absolute;
    left:5px;
    position:top;
}

HTML

<nav id = "thisNav">
        <ul>
            <li>
                <a href="#"><span></span>one</a>
                <ul>
                    <li><a href="#">sub1</a></li>
                    <li><a href="#">sub2</a></li>
                    <li><a href="#">sub3</a></li>
                </ul>
            </li>

            <li>
                <a href="#"><span></span>two</a>
                <ul>
                    <li><a href="#">sub1</a></li>
                    <li><a href="#">sub2</a></li>
                    <li><a href="#">sub3</a></li>
                </ul>
            </li>
    </ul>
</nav>
4

2 に答える 2

1

あなたのフィドルでいくつかのcssを変更しました

#thisNav ul ul{
    border-top: 1px solid #e9e9e9;
    display: none;
    width: 100%;
}

#thisNav ul ul li{
    width: 100%;
    background: #f1f1f1;
    border: 1px solid #e9e9e9;
    border-top: 0;
}
于 2013-07-29T15:29:36.550 に答える