2017-08-30 53 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'); 
} 
});