侧边栏

侧边栏

这里提供一个基础的侧边栏代码模板,可以根据实际需求调整样式或内容。

建议将侧边栏代码与全局美化样式分段放置,可避免样式冲突问题。

<html lang="zh">
<head>
  <style>
    .sidebar-wrapper {
      position: fixed;
      top: 60%;
      right: 0;
      transform: translateY(-50%);
      z-index: 1000;
      max-height: 90vh;
      overflow: auto;
    }
 
    details.sidebar {
      width: 80px;
      height: 40px;
      transition: width 0.3s ease, height 0.3s ease;
    }
 
    details.sidebar[open] {
      width: 250px;
      height: 300px;
    }
 
    summary.toggle-button {
      list-style: none;
      cursor: pointer;
      display: flex;
      height: 50px;
      width: 100%;
      border: none;
      padding: 0;
      background: none;
    }
 
    summary.toggle-button::-webkit-details-marker {
      display: none;
    }
 
    .btn-left {
      width: 15px;
      background-color: #F3D6AA;
    }
 
    .btn-right {
      flex: 1;
      color: #474376;
      font-weight: 800;
      padding: 10px 8px;
      background-color: #F8E9D4;
      text-align: left;
    }
 
    details.sidebar:hover {
      filter: drop-shadow(-3px 3px 5px rgba(100, 96, 93, 0.2));
    }
 
    .sidebar-content {
      background-color: #F8E9D4;
      overflow-y: auto;
      max-height: calc(90vh - 50px);
    }
 
    .note-content {
      padding: 20px;
      background-color: rgba(255, 255, 255, 0.5);
      border-radius: 3px;
    }
 
    .text-block {
      color: #58538b;
      margin-bottom: 10px;
      line-height: 1.6;
    }
 
    .title-block {
      font-size: 1.25rem;
      font-weight: bold;
      margin-bottom: 12px;
    }
 
    .image-wrapper {
      text-align: center;
      margin: 15px 0;
    }
 
    .image-wrapper img {
      width: 100px;
      height: 100px;
      border: 2px dashed #f9e6ca;
      border-radius: 8px;
      box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
      max-width: 100%;
    }
 
    .collapsible {
      margin-bottom: 15px;
    }
 
    .collapsible summary {
      cursor: pointer;
      font-weight: bold;
      color: #474376;
    }
 
    .collapsible-content {
      margin-top: 8px;
      padding: 10px;
      background: rgba(255, 255, 255, 0.6);
      border-radius: 4px;
    }
 
    .note-tip {
      font-style: italic;
      color: #555;
    }
 
    details summary:focus {
      outline: none;
    }
    
  </style>
</head>
 
<body>
  <div class="sidebar-wrapper">
    <details class="sidebar">
      <summary class="toggle-button">
        <div class="btn-left"></div>
        <div class="btn-right">侧边栏</div>
      </summary>
      <div class="sidebar-content">
        <div class="note-content">
          <div class="text-block title-block" >mumu小便签</div>
          <div class="text-block">这是一个模拟真实便签的侧边栏,您可以在这里记录重要事项、待办清单或其他任何内容。</div>
          <div class="image-wrapper">
            <img src="https://cdn.mufy.ai/images/9273a3b0-3fc5-46ef-90ec-2d44ff06fe00/public" alt="sticky-note-illustration">
          </div>
          <details class="collapsible">
            <summary>点击展开更多内容</summary>
            <div class="collapsible-content">
              <div class="text-block">这里是一个折叠区域,用于展示补充说明、操作提示或次要信息。</div>
              <ul>
               <div class="text-block">支持内容折叠,避免信息冗杂</div>
                <div class="text-block">适合展示扩展说明</div>
               <div class="text-block">点击 summary 进行开关</div>
              </ul>
            </div>
          </details>
          <details class="collapsible">
            <summary>点击展开更多内容</summary>
            <div class="collapsible-content">
              <div class="text-block">这里是一个折叠区域,用于展示补充说明、操作提示或次要信息。</div>
              <ul>
               <div class="text-block">支持内容折叠,避免信息冗杂</div>
                <div class="text-block">适合展示扩展说明</div>
               <div class="text-block">点击 summary 进行开关</div>
              </ul>
            </div>
          </details>
          <div class="note-tip text-block">
            喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵‘’‘
          </div>
        </div>
      </div>
    </details>
  </div>
</body>
</html>

Last updated