CSS scroll-behavior 示例

CSS scroll-behavior1 个文件更新于 2026-04-06
html公开前 25 行,完整代码需登录
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS scroll-behavior 示例</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    html {
      scroll-behavior: smooth;
    }

    body {
      font-family: Arial, sans-serif;
      line-height: 1.6;
    }

    .nav {
      position: fixed;
      top: 0;

登录后可以查看完整源码、在线编辑并实时预览运行效果。