安排导航彼此之下的项目

时间:2014-09-28 07:25:17

标签: php jquery html css html5

我有一个像这样的菜单栏

<header>
        <nav>
            <a href="#">Home</a>
            <a href="#">Our Story</a>
            <a href="#">Tools</a>
            <a href="#">Technology</a>
            <a href="#">Pricing</a>
            <a href="#">Contact</a>
            <a href="#">Careers</a>
        </nav>
    </header>

CSS如下

header {
    position: fixed;
    width: 100%;
    height: 65px;
    opacity: 0.8;
    background-color: #fcfcfc;
    border-bottom: 5px solid #53bf6b;
    z-index: 10;
}

header nav {
    padding-top: 10px;
    text-align: center;
}

header nav a {
    text-decoration: none;
    font-family: 'Roboto', sans-serif;
    font-weight: 300;
    font-size: 26px;
    padding-right: 20px;
    color: #f35626;
    background-image: -webkit-linear-gradient(92deg, #f35626, #feab3a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-animation: hue 60s infinite linear;
}

当用户调整大小时,我想在下面跟随导航A(垂直对齐)我该怎么做?

@media only screen and (min-width: 150px) and (max-width: 550px) {
 /* I must set the code to arrange the nav a items here */
}

在调整大小时,如何使导航项目垂直相互跟随?

2 个答案:

答案 0 :(得分:2)

使用那里的显示块: http://jsfiddle.net/c0y518bn/

@media only screen and (min-width: 150px) and (max-width: 550px) {
    nav a {display: block;}
}

修正了最低版本:http://jsfiddle.net/c0y518bn/1/

答案 1 :(得分:0)

header nav a {

display: block; /* you can also try position:relative; */

}