调整窗口大小时,我的用户栏中的项目正在移动(CSS)

时间:2014-09-03 21:27:24

标签: html css css3

因此,我正在使用此网站的用户栏 - http://beta.btcbidder.com

我遇到的问题是 - 我终于,最终将所有 li 类型的项目排成一行,它们应该在我的屏幕上使用CSS。

话虽如此,我有一些重新调整大小的问题。当我缩小窗口时,我的搜索框和注册/登录项移动到用户栏下方的新行,我真的不知道如何解决这个问题。

想法?

我目前的CSS Schema:

menu#userbar > li {
    float: left;
    position: relative;
}

menu#userbar > li a {
    border: 0px none transparent;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-right: 1px solid rgba(128, 0, 0, 0.2);
    color: inherit;
    display: block;
    text-decoration: none;
    height: 16px;
    padding: 8px 4px;
}
menu#userbar > li a:hover {
    background-color: rgba(255, 255, 255, 0.6);
    text-decoration: underline;
}

menu#userbar > li:first-of-type {
    padding-left: 10px;
}
menu#userbar > li:first-child a {
    background-image: url('/media/images/logo.png');
    background-position: left;
    background-repeat: no-repeat;
    width: 73px;
    height: 40px;
}
menu#userbar > li:nth-last-child(3) {
    padding-left: 500px;
}
menu#userbar > li > *:first-child {
    display: block;
    height: 16px;
    overflow: hidden;
    padding: 8px 4px;
}

menu#userbar > li > menu {
    background-color: #ADADAD; /* fallback */
    background-color: rgba(173, 173, 173, 0.9);
    border-radius: 0px 0px 2px 2px;
    box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.2);
    display: none;
    list-style-type: none;
    position: absolute;
    text-align: left;
    top: 32px;
    z-index: 99999;
}
menu#userbar > li:hover > menu {
    display: block;
}
menu#userbar > li > menu li {
    min-width: 160px;
    white-space: nowrap;
}

1 个答案:

答案 0 :(得分:0)

1 - 设置padding-right: 150px;(根据需要更改)而非padding-left: 500px;设为menu#userbar > li:nth-last-child(3)

<强> CSS:

menu#userbar > li:nth-last-child(3) {
    padding-right: 150px; /* change as you want */
}

2 - 更改登录注册 <li>代码的顺序并使用float: right;

<强> HTML:

<!--THIS ENDS THE SEARCH BAR       -->
<!----------------------------------->

<li class="right" style="float: right;">
    <a href="http://beta.btcbidder.com/login/">Login</a>
</li>
<li style="float: right;">
    <a href="">Signup</a>
</li>

[EDITED]

我已检查过您的网站,现在您需要将CSS menu#userbar > li:last-of-type更改为menu#userbar > li:nth-child(5)

使用此:

menu#userbar > li:nth-child(5) {
    padding-right: 120px; /* change as you want */
}

代替:

menu#userbar > li:last-of-type { /* change this with the above CSS */
    padding-right: 192px;
}
相关问题