How to change drop-down menu to drop-up menu

2019-08-31 12:40发布

问题:

I have this menu bar: http://jsfiddle.net/PtQAP/ and I need to put it to the bottom and the drop-down menu change to drop-up menu. How would I do that?

css:

ul, li, a {
    margin: 0;
    padding: 0;
}
li {
    list-style: none;
}
a {
    text-decoration: none;
    color: #000000;
}

ul > li {
    float: left;
}
ul > li a {
    color: #fff;
    font-weight: bold;
    line-height: 40px;
    height:40px;
    display:block;
    padding:0px 10px;
}
ul li a:hover {
    background: #666666;
}
ul li ul {
    display: none;
    position: absolute;
    background: #333333;
}
ul li ul li {
    float: none;
    line-height: 40px;
    height: 40px;
}

Thanks for the answers.

回答1:

give the bar a position of fixed, and set its bottom to 0px, then set your menu to have a bottom of the height of your bar, in this case 40px

div {
    background: #999999;
    height: 40px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    color: #000000;
    margin: -8px;
    width:100%;
    position:fixed;
    bottom:0px;
    left:0px;
}

ul li ul {
    display: none;
    position: absolute;
    background: #333333;
    bottom:40px;
}

JSFiddle Demo