2017-08-30 77 views

回答

1

tutorial由Josh Morony应该让你开始!玩得开心!

+0

谢谢同名!这是完美的 –

+0

没问题,总是乐于帮忙! – David

+0

好的答案不仅仅是简单地引用外部网站,并建议OP引用它。主要引用外部网站的答案应该包括信息摘要,以便它成为主要来源以及参考资料([更多信息...](https://meta.stackexchange.com/questions/8231/) -answers - 即,刚刚包含链接别处 - 真的好 - 答案)) – sebaferreras

2
I hope this will help you. 

<header> 
    <div class="header-banner"> 
</div> 

<nav> 
<ul> 
    <li><a href="#">$4,456-5,778 your text</a></li> 
</ul> 
</nav> 
</header> 
<section class="content"> 
    <p>Here add huge dummy content to check scroll position.</p> 
</section> 



header { 
height:360px; 
} 
.header-banner { 
background-color: red; 
width: 100%; 
height: 300px; 
} 
.fixed-header { 
    position: fixed; 
    top:0; left:0; 
    width: 100%; 
    } 
    nav { 
    width:100%; 
    height:60px; 
    background: #292f36; 
    postion:fixed; 
    z-index:10; 
    } 
    nav ul { 
    list-style-type: none; 
    margin: 0 auto; 
    padding-left:0; 
    text-align:right; 
    width: 960px; 
    max-width: 100%; 
    } 
    nav ul li { 
    display: inline-block; 
    line-height: 60px; 
    margin-left: 10px; 
    } 
    nav ul li a { 
    text-decoration: none; 
    color: #a9abae; 
    } 


    $(window).scroll(function(){ 
if ($(window).scrollTop() >= 300) { 
    $('nav').addClass('fixed-header'); 
} 
else { 
    $('nav').removeClass('fixed-header'); 
} 
});