Menu
CoddyTech

打开功能

Coddy 侧边栏|前端项目 课程的第 13 课,共 13 课。

challenge icon

挑战

简单

现在,用同样的方法,选中 #openSidebarBtn,将类 'sidebar' 的 right 属性设置为 0 像素。

亲手试试

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
  <title>Mobile Sidebar</title>
</head>
<body>
  <button id="openSidebarBtn">Open</button>
  <div id="sidebar" class="sidebar">
    <button id="closeSidebarBtn">Close</button>
    <!-- 在这里添加侧边栏内容 -->
    <p>Home</p>
    <p>About</p>
    <p>Services</p>
    <p>Contact</p>
  </div>
  <script src="script.js"></script>
</body>
</html>

侧边栏|前端项目中的所有课

自己练习: Web 在线编辑器