为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

智慧大石 2021-12-02 19:49:32
我正在寻找右侧的侧边栏 manu。我想要一个隐藏的侧边栏,当你滚动它时会出现。与https://www.psx.com.pk 的侧边栏非常相似
查看完整描述

2 回答

?
繁花不似锦

TA贡献1851条经验 获得超4个赞

像这样的东西:


HTML


<div>

 <ul>

  <li>1</li>

  <li>2</li>

  <li>3</li>

 </ul>

</div>

CSS:


body {

  overflow-x: hidden;

}


div {

 background: #f4f4f4;

 position: absolute;

 right: -200px;

 width: 300px;

 height: 300px;

 transition: all 0.2s;

 cursor: pointer;

}


div:hover {

 right: 0;

}


查看完整回答
反对 回复 2021-12-02
?
当年话下

TA贡献1890条经验 获得超9个赞

这对你来说可能是一个好的开始。更改一些选项,您就可以开始了。


    <!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1">

<style>

body {

  font-family: "Lato", sans-serif;

}


.sidebar {

  height: 100%;

  width: 0;

  position: fixed;

  z-index: 1;

  top: 0;

  left: 0;

  background-color: #111;

  overflow-x: hidden;

  transition: 0.5s;

  padding-top: 60px;

}


.sidebar a {

  padding: 8px 8px 8px 32px;

  text-decoration: none;

  font-size: 25px;

  color: #818181;

  display: block;

  transition: 0.3s;

}


.sidebar a:hover {

  color: #f1f1f1;

}


.sidebar .closebtn {

  position: absolute;

  top: 0;

  right: 25px;

  font-size: 36px;

  margin-left: 50px;

}


.openbtn {

  font-size: 20px;

  cursor: pointer;

  background-color: #111;

  color: white;

  padding: 10px 15px;

  border: none;

}


.openbtn:hover {

  background-color: #444;

}


#main {

  transition: margin-left .5s;

  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) {

  .sidebar {padding-top: 15px;}

  .sidebar a {font-size: 18px;}

}

</style>

</head>

<body>


<div id="mySidebar" class="sidebar">

  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>

  <a href="#">About</a>

  <a href="#">Services</a>

  <a href="#">Clients</a>

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

</div>


<div id="main">

  <button class="openbtn" onclick="openNav()">☰ Toggle Sidebar</button>  

  <h2>Collapsed Sidebar</h2>

  <p>Click on the hamburger menu/bar icon to open the sidebar, and push this content to the right.</p>

</div>


<script>

function openNav() {

  document.getElementById("mySidebar").style.width = "250px";

  document.getElementById("main").style.marginLeft = "250px";

}


function closeNav() {

  document.getElementById("mySidebar").style.width = "0";

  document.getElementById("main").style.marginLeft= "0";

}

</script>


</body>

</html> 



查看完整回答
反对 回复 2021-12-02
  • 2 回答
  • 0 关注
  • 200 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信