第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如果滾動(dòng)頁(yè)面時(shí)移動(dòng)導(dǎo)航欄處于打開(kāi)狀態(tài),如何關(guān)閉?

如果滾動(dòng)頁(yè)面時(shí)移動(dòng)導(dǎo)航欄處于打開(kāi)狀態(tài),如何關(guān)閉?

FFIVE 2022-08-04 16:09:37
如果導(dǎo)航欄在網(wǎng)站的移動(dòng)視圖中打開(kāi),如何在頁(yè)面滾動(dòng)時(shí)關(guān)閉導(dǎo)航欄?最簡(jiǎn)單的方法(css或js)
查看完整描述

1 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊

好吧,對(duì)我來(lái)說(shuō),我更喜歡使用JS。這是我從w3schools得到的一個(gè)例子,它正在與導(dǎo)航欄的Web和移動(dòng)視圖一起使用


var prevScrollpos = window.pageYOffset;

window.onscroll = function() {

  var currentScrollPos = window.pageYOffset;

  if (prevScrollpos > currentScrollPos) {

    document.getElementById("navbar").style.top = "0";

  } else {

    document.getElementById("navbar").style.top = "-50px";

  }

  prevScrollpos = currentScrollPos;

}

body {

  margin: 0;

  background-color: #f1f1f1;

  font-family: Arial, Helvetica, sans-serif;

}


#navbar {

  background-color: #333;

  position: fixed;

  top: 0;

  width: 100%;

  display: block;

  transition: top 0.3s;

}


#navbar a {

  float: left;

  display: block;

  color: #f2f2f2;

  text-align: center;

  padding: 15px;

  text-decoration: none;

  font-size: 17px;

}


#navbar a:hover {

  background-color: #ddd;

  color: black;

}

<body>


<div id="navbar">

  <a href="#home">Home</a>

  <a href="#news">News</a>

  <a href="#contact">Contact</a>

</div>


<div style="padding:15px 15px 2500px;font-size:30px;margin-top:30px;">

  <p><b>This example demonstrates how to hide a navbar when the user starts to scroll the page.</b></p>

  <p>Scroll down this frame to see the effect!</p>

  <p>Scroll up to show the navbar.</p>

  <p>Lorem ipsum dolor dummy text sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

  <p>Lorem ipsum dolor dummy text sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>


</body>


查看完整回答
反對(duì) 回復(fù) 2022-08-04
  • 1 回答
  • 0 關(guān)注
  • 159 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)