doujiao9866
doujiao9866
2014-09-28 07:25

安排导航彼此之下的项目

I have a menu bar like this

<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>

The CSS is follows

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;
}

And when the user resizes I want to Nav A to be followed below (align vertically) How can I do this ?

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

What should I do to make the nav a items follow each other vertically when resized ?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • drbae3964 drbae3964 7年前

    Use display block like there: http://jsfiddle.net/c0y518bn/

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

    Fixed border-bottom version: http://jsfiddle.net/c0y518bn/1/

    点赞 评论 复制链接分享
  • douhe4336 douhe4336 7年前
    header nav a {
    
    display: block; /* you can also try position:relative; */
    
    }
    
    点赞 评论 复制链接分享

相关推荐