【HTML+CSS】固定在页面顶端的导航条

HTML




    
    
    
    固定在页面顶端的导航条
    
    


    

    

CSS

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.header {
    width: 100%;
    height: 800px;
    background-image: url(bg.png);
    background-size: cover;

}

.nav {
    width: 100%;
    padding: 20px;
    position: fixed;
    top: 0;
    text-align: center;
    transition: .5s;
}

.nav ul li {
    list-style-type: none;
    display: inline-block;
    padding: 10px 50px;
    font-size: 24px;
    font-family: sans-serif;
    cursor: pointer;
    border-radius: 10px;
    transition: .5s;
}
.nav ul li a{
    color: #fff;
    text-decoration:none;
}


.nav ul li:hover {
    background: #f39c12;
}

.box {
    width: 80%;
    height: 2000px;
    margin: 20px auto;
}

你可能感兴趣的:(【HTML+CSS】固定在页面顶端的导航条)