nuxt / nuxt

The Intuitive Vue Framework.
https://nuxt.com
MIT License
57.04k stars 5.25k forks source link

scroll-margin-top does not work in Nuxt version 3.16.1 scroll-margin-top #31755

Open AABBCC-cloud opened 1 month ago

AABBCC-cloud commented 1 month ago

Environment

{ "name": "nuxt-app", "private": true, "type": "module", "scripts": { "build": "nuxt build", "dev": "nuxt dev", "generate": "nuxt generate", "preview": "nuxt preview", "postinstall": "nuxt prepare" }, "dependencies": { "nuxt": "^3.16.2", "vue": "^3.5.13", "vue-router": "^4.5.0" } }

Reproduction

<template>
  <div style="height: 2000px">
    <nav data-v-433a9abd="">
      <div data-v-0a431294="" data-v-433a9abd="" class="navbar">
        <div data-v-0a431294="" class="brand-title">
          <a data-v-0a431294="" href="/">ABC's Blog</a>
        </div>
        <a data-v-0a431294="" href="#" class="toggle-button"
          ><span data-v-0a431294="" class="bar"></span
          ><span data-v-0a431294="" class="bar"></span
          ><span data-v-0a431294="" class="bar"></span
        ></a>
        <div data-v-0a431294="" class="navbar-links">
          <ul data-v-0a431294="">
            <li data-v-0a431294="">
              <a data-v-0a431294="" href="/" class="">首页</a>
            </li>
            <li data-v-0a431294="">
              <a data-v-0a431294="" href="/category" class="">分类</a>
            </li>
            <li data-v-0a431294="">
              <a data-v-0a431294="" href="/tag" class="">标签</a>
            </li>
            <li data-v-0a431294="">
              <a data-v-0a431294="" href="/about" class="">关于</a>
            </li>
          </ul>
        </div>
        <div data-v-0a431294="" class="search-box">
          <div data-v-0a431294="" class="el-input el-input--prefix">
            <!-- input --><!-- prepend slot --><!--v-if-->
            <div class="el-input__wrapper" tabindex="-1">
              <!-- prefix slot --><span class="el-input__prefix"
                ><span class="el-input__prefix-inner"
                  ><i class="el-icon el-input__icon"
                    ><el-icon-search></el-icon-search></i></span></span
              ><input
                class="el-input__inner"
                type="text"
                autocomplete="off"
                tabindex="0"
                placeholder="搜索"
                id="el-id-1024-8"
              /><!-- suffix slot --><!--v-if-->
            </div>
            <!-- append slot --><!--v-if-->
          </div>
          <button
            data-v-0a431294=""
            aria-disabled="false"
            type="button"
            class="el-button el-button--primary"
          >
            <!--v-if--><span class="">搜索</span>
          </button>
        </div>
      </div>
    </nav>

    <main data-v-433a9abd="">
      <div
        data-v-09ef3bc5=""
        data-v-433a9abd=""
        class="el-row"
        style="display: flex; flex-direction: row; height: 100%"
      >
        <!-- 侧边栏部分 -->
        <div
          data-v-09ef3bc5=""
          class="el-col el-col-24 el-col-xs-0 el-col-md-7 hidden-sm-and-down"
        >
          <aside data-v-09ef3bc5="" class="sidebar">
            <h1 data-v-09ef3bc5="" class="title">文章导航</h1>
            <ul data-v-09ef3bc5="" id="toc-list">
              <li data-v-09ef3bc5="">
                <a data-v-09ef3bc5="" class="toc-h2 active" href="#1">12121</a>
              </li>
              <li data-v-09ef3bc5="">
                <a data-v-09ef3bc5="" class="toc-h2" href="#2"
                  >哈分为氛围分为</a
                >
              </li>
            </ul>
          </aside>
        </div>
        <!-- 主要内容区域 -->
        <div
          data-v-09ef3bc5=""
          class="el-col el-col-24 el-col-xs-24 el-col-md-17"
        >
          <!-- 当内容加载完成后显示的内容 --><span
            data-v-09ef3bc5=""
            style="color: rgb(151, 168, 177); cursor: text"
            >文章详情</span
          ><!--v-if-->
          <div data-v-09ef3bc5="" class="content">
            <article data-v-09ef3bc5="">
              <div data-v-09ef3bc5="" class="v-md-editor-preview">
                <h2><a id="1" class="h2">12121</a></h2>
                <p>
                  发的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop = ‘90px’,观察是否生效。
                </p>
                <h2><a id="2" class="h2">哈分为氛围分为</a></h2>
                <p>
                  的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop =
                  ‘90px’,观察是否生效。的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop =
                  ‘90px’,观察是否生效。的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop = ‘90px’,观察是否生效。
                  的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop = ‘90px’,观察是否生效。
                  的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop = ‘90px’,观察是否生效。
                  的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop =
                  ‘90px’,观察是否生效。的哇二十分我发个我回国复位会给人文化
                  官方为官为人个人几个人根据二零经过了人建立个人隔热隔热检查计算后的样式:
                  在浏览器开发者工具中,检查目标元素的最终 scroll-margin-top
                  值是否为 90px。 确认是否有其他样式覆盖了你的设置。
                  简化代码测试: 移除所有 JavaScript
                  滚动逻辑,仅通过直接点击锚点链接测试是否抖动。
                  移除所有过渡效果,观察是否问题消失。
                  使用浏览器控制台动态设置: 在控制台中直接执行
                  element.style.scrollMarginTop = ‘90px’,观察是否生效。
                </p>
              </div>
            </article>
            <div data-v-09ef3bc5="" class="article-description">
              <div data-v-09ef3bc5="" class="article-time">
                发布时间:2025-04-09
              </div>
              <div data-v-f7175cb3="" data-v-09ef3bc5="" class="comment-box">
                <!-- 发布评论 -->
                <div data-v-f7175cb3="" class="comment-head">
                  <img
                    data-v-f7175cb3=""
                    src="/_nuxt/assets/anno.jpeg"
                    alt=""
                  /><textarea
                    data-v-f7175cb3=""
                    placeholder="请输入评论 . . ."
                  ></textarea
                  ><button data-v-f7175cb3="">发表评论</button>
                </div>
                <h1 data-v-f7175cb3="">全部评论</h1>
                <!-- 评论列表 -->
                <div data-v-f7175cb3="" class="content"></div>
                <!-- 分页 --><!--v-if--><!-- 评论人信息 -->
                <div class="el-overlay" style="z-index: 2002; display: none">
                  <div
                    role="dialog"
                    aria-modal="true"
                    aria-label="留下你的信息"
                    aria-describedby="el-id-1024-10"
                    class="el-overlay-dialog"
                  ></div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
  </div>
</template>

<script setup>
definePageMeta({
  layout: false, // 禁用布局
});
</script>

<style scoped>
.navbar {
  background-color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  color: #303133;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  /* 使内容两端对齐 */
  align-items: center;
  position: relative;
  /* 为绝对定位的按钮提供上下文 */
}

.brand-title a {
  color: #333333;
  font-weight: bold;
  text-decoration: none;
  /* 去除下划线 */
  font-size: 1.5em;
}

.toggle-button {
  display: none;
  flex-direction: column;
  cursor: pointer;
}

.bar {
  height: 3px;
  width: 25px;
  background-color: #aaa;
  margin: 3px 0;
  transition: 0.4s;
}

.search-box {
  display: flex;
  align-items: center;
}

.search-box input {
  padding: 0.5rem;
  border: none;
  border-radius: 5px 0 0 5px;
  outline: none;
}

.search-box input::placeholder {
  color: #aaa;
}

.navbar-links {
  display: flex;
  flex: 1;
  /* 使导航链接占据剩余空间 */
}

.navbar-links ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  justify-content: space-around;
  /* 在导航链接之间添加间距 */
  flex: 1;
  /* 使导航链接占据剩余空间 */
}

.navbar-links li a {
  text-decoration: none;
  color: #303133;
  padding: 1rem;
  display: block;
  transition: color 0.3s;
  /* 添加过渡效果 */
}

.navbar-links li:hover {
  background-color: #409eff;
  border-radius: 5px;
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-title {
    text-align: left;
    width: 100%;
    order: -1;
  }

  .toggle-button {
    display: flex;
    position: absolute;
    top: 1rem;
    right: 2rem;
  }

  .search-box {
    width: 100%;
    margin-top: 1rem;
    order: 1;
  }

  .search-box input {
    width: 100%;
    border-radius: 5px;
  }

  .navbar-links {
    display: none;
    width: 100%;
    flex-direction: column;
    order: 2;
  }

  .navbar-links ul {
    flex-direction: column;
    width: 100%;
  }

  .navbar-links.active {
    display: flex;
  }
}
</style>

<style scoped>
.navbar {
  background-color: transparent;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  color: #303133;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  /* 使内容两端对齐 */
  align-items: center;
  position: relative;
  /* 为绝对定位的按钮提供上下文 */
}

.brand-title a {
  color: #333333;
  font-weight: bold;
  text-decoration: none;
  /* 去除下划线 */
  font-size: 1.5em;
}

.toggle-button {
  display: none;
  flex-direction: column;
  cursor: pointer;
}

.bar {
  height: 3px;
  width: 25px;
  background-color: #aaa;
  margin: 3px 0;
  transition: 0.4s;
}

.search-box {
  display: flex;
  align-items: center;
}

.search-box input {
  padding: 0.5rem;
  border: none;
  border-radius: 5px 0 0 5px;
  outline: none;
}

.search-box input::placeholder {
  color: #aaa;
}

.navbar-links {
  display: flex;
  flex: 1;
  /* 使导航链接占据剩余空间 */
}

.navbar-links ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  justify-content: space-around;
  /* 在导航链接之间添加间距 */
  flex: 1;
  /* 使导航链接占据剩余空间 */
}

.navbar-links li a {
  text-decoration: none;
  color: #303133;
  padding: 1rem;
  display: block;
  transition: color 0.3s;
  /* 添加过渡效果 */
}

.navbar-links li:hover {
  background-color: #409eff;
  border-radius: 5px;
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-title {
    text-align: left;
    width: 100%;
    order: -1;
  }

  .toggle-button {
    display: flex;
    position: absolute;
    top: 1rem;
    right: 2rem;
  }

  .search-box {
    width: 100%;
    margin-top: 1rem;
    order: 1;
  }

  .search-box input {
    width: 100%;
    border-radius: 5px;
  }

  .navbar-links {
    display: none;
    width: 100%;
    flex-direction: column;
    order: 2;
  }

  .navbar-links ul {
    flex-direction: column;
    width: 100%;
  }

  .navbar-links.active {
    display: flex;
  }
}
</style>

<style>
/* 选择所有带有 id 属性的 <a> 元素 */
.content .v-md-editor-preview a[id] {
  scroll-margin-top: 90px !important;
  transition: none;
  /* 移除过渡 */
  /* color: red; */
  /* background: red; */
}
</style>
<style scoped>
nav {
  margin: 0em;
  padding: 0em;
  width: 100%;
  position: fixed;
  background: transparent;
  /* height: 90px; */
  z-index: 1000;
}

main {
  position: relative;
  top: 90px;
  /* width: 80%; */
  /* margin: 0 auto;
gap: 1em;
flex: 1; */
  /* padding: 1em; */
  /* transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out; */
}

/* footer {
position: relative;
top: 6rem;
}

@media (max-width: 768px) {
main {
  width: 90%;
  top: 7em;
}
} */
</style>

Describe the bug

scroll-margin-top does not work in Nuxt version 3.16.1 scroll-margin-top

Additional context

scroll-margin-top does not work in Nuxt version 3.16.1 scroll-margin-top

Logs

github-actions[bot] commented 1 month ago

Would you be able to provide a reproduction? 🙏

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a couple of templates for starting with a minimal reproduction: 👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz 👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/minimal-reproducible-example)
AABBCC-cloud commented 1 month ago

scroll-margin-top does not work in Nuxt version 3.16.1 scroll-margin-top This is an example

<template>
  <nav></nav>
  <main>
    <!-- 侧边栏部分 -->
    <aside
      style="
        width: 40%;
        position: sticky;
        top: 90px;
        height: calc(100vh - 150px);
      "
    >
      <h1>Article Navigation</h1>
      <ul id="toc-list">
        <li data-v-09ef3bc5="">
          <a href="#1">One</a>
        </li>
        <li>
          <a href="#2">Two</a>
        </li>
        <li>
          <a href="#3">Three</a>
        </li>
      </ul>
    </aside>
    <div class="content">
      <h1><a id="1">One</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
      <h1><a id="2">Two</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
      <h1><a id="3">Three</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
    </div>
  </main>
</template>

<script setup>
definePageMeta({
  layout: false, // 禁用布局
});
</script>
<style scoped>
nav {
  width: 100%;
  height: 90px;
  background-color: aqua;
  position: fixed;
  padding: 0px;
  margin: 0;
}
main {
  display: flex;
}
.content {
  width: 60%;
  height: 2000px;
}
.content a {
  scroll-margin-top: 90px;
}
</style>
rylanharper commented 1 month ago

This seems to be a css error on your part.. scroll-margin-top requires a scroll-snap container for this property to work. You have none on your .content class. Here is the MDN reference.

AABBCC-cloud commented 1 month ago

Really, I put it on NUXT invalid, put it on HTML valid

On Html is valid

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <nav></nav>
    <main>
        <!-- 侧边栏部分 -->
        <aside style="
        width: 40%;
        position: sticky;
        top: 90px;
        height: calc(100vh - 150px);
    ">
            <h1>Article Navigation</h1>
            <ul id="toc-list">
                <li data-v-09ef3bc5="">
                    <a href="#1">One</a>
                </li>
                <li>
                    <a href="#2">Two</a>
                </li>
                <li>
                    <a href="#3">Three</a>
                </li>
            </ul>
        </aside>
        <div class="content">
            <h1><a id="1">One</a></h1>
            <p>
                With the development of the e-commerce industry, express delivery has
                become an indispensable part of daily life, and various delivery
                platforms have seized this market demand and launched innovative express
                delivery CPS models. As a brand new 2.0 automation platform, it has
                attracted a large number of industry experts to join with its strong
                platform background and convenient operation mode. In this article, we
                will provide a detailed introduction to the injection testing process
                that has been widely sent, beginner operation tutorials, and tips on how
                to easily make money through this platform. 1、 Send platform
                introductions one after another Yiyunqi is an online shipping platform
                based on CPS for express delivery. Users can earn a lot of money through
                promotion, which is particularly suitable for those who want to easily
                start a business during their leisure time. By sending messages one
                after another, users do not need to manually place orders themselves,
                they only need to become agents of the platform and promote their
                exclusive invitation Ma. The design of the platform is extremely
                user-friendly, without requiring users to spend too much time and
                energy. With simple operations, the dual goals of saving money and
                making money can be achieved. We have a strong cooperative background
                and are supported by the well-known platform Meiguang, ensuring its
                stability and market recognition. After completing the shipping
                operation on the platform, users cooperate with major courier companies
                to provide services to users at the lowest cost price, while also
                allowing Daili to receive corresponding rewards. 彩
            </p>
            <h1><a id="2">Two</a></h1>
            <p>
                With the development of the e-commerce industry, express delivery has
                become an indispensable part of daily life, and various delivery
                platforms have seized this market demand and launched innovative express
                delivery CPS models. As a brand new 2.0 automation platform, it has
                attracted a large number of industry experts to join with its strong
                platform background and convenient operation mode. In this article, we
                will provide a detailed introduction to the injection testing process
                that has been widely sent, beginner operation tutorials, and tips on how
                to easily make money through this platform. 1、 Send platform
                introductions one after another Yiyunqi is an online shipping platform
                based on CPS for express delivery. Users can earn a lot of money through
                promotion, which is particularly suitable for those who want to easily
                start a business during their leisure time. By sending messages one
                after another, users do not need to manually place orders themselves,
                they only need to become agents of the platform and promote their
                exclusive invitation Ma. The design of the platform is extremely
                user-friendly, without requiring users to spend too much time and
                energy. With simple operations, the dual goals of saving money and
                making money can be achieved. We have a strong cooperative background
                and are supported by the well-known platform Meiguang, ensuring its
                stability and market recognition. After completing the shipping
                operation on the platform, users cooperate with major courier companies
                to provide services to users at the lowest cost price, while also
                allowing Daili to receive corresponding rewards. 彩
            </p>
            <h1><a id="3">Three</a></h1>
            <p>
                With the development of the e-commerce industry, express delivery has
                become an indispensable part of daily life, and various delivery
                platforms have seized this market demand and launched innovative express
                delivery CPS models. As a brand new 2.0 automation platform, it has
                attracted a large number of industry experts to join with its strong
                platform background and convenient operation mode. In this article, we
                will provide a detailed introduction to the injection testing process
                that has been widely sent, beginner operation tutorials, and tips on how
                to easily make money through this platform. 1、 Send platform
                introductions one after another Yiyunqi is an online shipping platform
                based on CPS for express delivery. Users can earn a lot of money through
                promotion, which is particularly suitable for those who want to easily
                start a business during their leisure time. By sending messages one
                after another, users do not need to manually place orders themselves,
                they only need to become agents of the platform and promote their
                exclusive invitation Ma. The design of the platform is extremely
                user-friendly, without requiring users to spend too much time and
                energy. With simple operations, the dual goals of saving money and
                making money can be achieved. We have a strong cooperative background
                and are supported by the well-known platform Meiguang, ensuring its
                stability and market recognition. After completing the shipping
                operation on the platform, users cooperate with major courier companies
                to provide services to users at the lowest cost price, while also
                allowing Daili to receive corresponding rewards. 彩
            </p>
        </div>
    </main>
</body>
<style>
    nav {
        width: 100%;
        height: 90px;
        background-color: aqua;
        position: fixed;
        padding: 0px;
        margin: 0;
    }

    main {
        display: flex;
    }

    .content {
        position: relative;
        top: 90px;
        width: 60%;
        height: 2000px;
    }

    .content a {
        scroll-margin-top: 90px;
    }
</style>

</html>

On NUXT is invalid

<template>
  <nav></nav>
  <main>
    <!-- 侧边栏部分 -->
    <aside
      style="
        width: 40%;
        position: sticky;
        top: 90px;
        height: calc(100vh - 150px);
      "
    >
      <h1>Article Navigation</h1>
      <ul id="toc-list">
        <li data-v-09ef3bc5="">
          <a href="#1">One</a>
        </li>
        <li>
          <a href="#2">Two</a>
        </li>
        <li>
          <a href="#3">Three</a>
        </li>
      </ul>
    </aside>
    <div class="content">
      <h1><a id="1">One</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
      <h1><a id="2">Two</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
      <h1><a id="3">Three</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
    </div>
  </main>
</template>

<script setup>
definePageMeta({
  layout: false, // 禁用布局
});
</script>
<style scoped>
nav {
  width: 100%;
  height: 90px;
  background-color: aqua;
  position: fixed;
  padding: 0px;
  margin: 0;
}
main {
  display: flex;
}
.content {
  width: 60%;
  position: relative;
  top: 90px;
  height: 2000px;
}
.content a {
  scroll-margin-top: 90px;
}
</style>
AABBCC-cloud commented 1 month ago

How did you do it? I'm still invalid

Snipaste_2025-04-15_20-12-35

app.vue

<template>
  <NuxtPage />
</template>
<style>
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}
</style>

test.vue

<template>
  <nav></nav>
  <main>
    <!-- 侧边栏部分 -->
    <aside
      style="
        width: 40%;
        position: sticky;
        top: 90px;
        height: calc(100vh - 150px);
      "
    >
      <h1>Article Navigation</h1>
      <ul id="toc-list">
        <li data-v-09ef3bc5="">
          <a href="#1">One</a>
        </li>
        <li>
          <a href="#2">Two</a>
        </li>
        <li>
          <a href="#3">Three</a>
        </li>
      </ul>
    </aside>
    <div class="content">
      <h1><a id="1">One</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
      <h1><a id="2">Two</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
      <h1><a id="3">Three</a></h1>
      <p>
        With the development of the e-commerce industry, express delivery has
        become an indispensable part of daily life, and various delivery
        platforms have seized this market demand and launched innovative express
        delivery CPS models. As a brand new 2.0 automation platform, it has
        attracted a large number of industry experts to join with its strong
        platform background and convenient operation mode. In this article, we
        will provide a detailed introduction to the injection testing process
        that has been widely sent, beginner operation tutorials, and tips on how
        to easily make money through this platform. 1、 Send platform
        introductions one after another Yiyunqi is an online shipping platform
        based on CPS for express delivery. Users can earn a lot of money through
        promotion, which is particularly suitable for those who want to easily
        start a business during their leisure time. By sending messages one
        after another, users do not need to manually place orders themselves,
        they only need to become agents of the platform and promote their
        exclusive invitation Ma. The design of the platform is extremely
        user-friendly, without requiring users to spend too much time and
        energy. With simple operations, the dual goals of saving money and
        making money can be achieved. We have a strong cooperative background
        and are supported by the well-known platform Meiguang, ensuring its
        stability and market recognition. After completing the shipping
        operation on the platform, users cooperate with major courier companies
        to provide services to users at the lowest cost price, while also
        allowing Daili to receive corresponding rewards. 彩
      </p>
    </div>
  </main>
</template>

<script setup>
definePageMeta({
  layout: false, // 禁用布局
});
</script>
<style scoped>
nav {
  width: 100%;
  height: 90px;
  background-color: aqua;
  position: fixed;
  padding: 0px;
  margin: 0;
}
main {
  display: flex;
}
.content {
  width: 60%;
  position: relative;
  top: 90px;
  height: 2000px;
}
.content a {
  scroll-margin-top: 90px;
}
</style>
AABBCC-cloud commented 1 month ago

On https://stackblitz.com/edit/github-aszmfiy7 it's still invalid.

Why can you?

AABBCC-cloud commented 3 weeks ago

Made playground for you - https://stackblitz.com/edit/github-9ukebr-h7jxu3sd?file=pages%2Findex.vue There's an offset when clicking anchor links

Nuxt version is different

Your version

My version

AABBCC-cloud commented 3 weeks ago

When can this bug be resolved? I hope to receive a reply