可悬停的侧边栏菜单或右侧

我正在寻找右侧的侧边栏 manu。我想要一个隐藏的侧边栏,当你滚动它时会出现。与https://www.psx.com.pk 的侧边栏非常相似


智慧大石
浏览 201回答 2
2回答

繁花不似锦

像这样的东西:HTML<div>&nbsp;<ul>&nbsp; <li>1</li>&nbsp; <li>2</li>&nbsp; <li>3</li>&nbsp;</ul></div>CSS:body {&nbsp; overflow-x: hidden;}div {&nbsp;background: #f4f4f4;&nbsp;position: absolute;&nbsp;right: -200px;&nbsp;width: 300px;&nbsp;height: 300px;&nbsp;transition: all 0.2s;&nbsp;cursor: pointer;}div:hover {&nbsp;right: 0;}

当年话下

这对你来说可能是一个好的开始。更改一些选项,您就可以开始了。&nbsp; &nbsp; <!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><style>body {&nbsp; font-family: "Lato", sans-serif;}.sidebar {&nbsp; height: 100%;&nbsp; width: 0;&nbsp; position: fixed;&nbsp; z-index: 1;&nbsp; top: 0;&nbsp; left: 0;&nbsp; background-color: #111;&nbsp; overflow-x: hidden;&nbsp; transition: 0.5s;&nbsp; padding-top: 60px;}.sidebar a {&nbsp; padding: 8px 8px 8px 32px;&nbsp; text-decoration: none;&nbsp; font-size: 25px;&nbsp; color: #818181;&nbsp; display: block;&nbsp; transition: 0.3s;}.sidebar a:hover {&nbsp; color: #f1f1f1;}.sidebar .closebtn {&nbsp; position: absolute;&nbsp; top: 0;&nbsp; right: 25px;&nbsp; font-size: 36px;&nbsp; margin-left: 50px;}.openbtn {&nbsp; font-size: 20px;&nbsp; cursor: pointer;&nbsp; background-color: #111;&nbsp; color: white;&nbsp; padding: 10px 15px;&nbsp; border: none;}.openbtn:hover {&nbsp; background-color: #444;}#main {&nbsp; transition: margin-left .5s;&nbsp; padding: 16px;}/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */@media screen and (max-height: 450px) {&nbsp; .sidebar {padding-top: 15px;}&nbsp; .sidebar a {font-size: 18px;}}</style></head><body><div id="mySidebar" class="sidebar">&nbsp; <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>&nbsp; <a href="#">About</a>&nbsp; <a href="#">Services</a>&nbsp; <a href="#">Clients</a>&nbsp; <a href="#">Contact</a></div><div id="main">&nbsp; <button class="openbtn" onclick="openNav()">☰ Toggle Sidebar</button>&nbsp;&nbsp;&nbsp; <h2>Collapsed Sidebar</h2>&nbsp; <p>Click on the hamburger menu/bar icon to open the sidebar, and push this content to the right.</p></div><script>function openNav() {&nbsp; document.getElementById("mySidebar").style.width = "250px";&nbsp; document.getElementById("main").style.marginLeft = "250px";}function closeNav() {&nbsp; document.getElementById("mySidebar").style.width = "0";&nbsp; document.getElementById("main").style.marginLeft= "0";}</script></body></html>&nbsp;
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript