naive-ui/demo/documentation/components/layout/enUS/scroll-to.demo.md
2020-12-12 14:44:44 +08:00

1.2 KiB

Scroll To

<n-button @click="$refs.sider.scrollTo({ top: 120, behavior: 'smooth' })">
  Sider Scroll to 120px
</n-button>
<n-button @click="$refs.content.scrollTo({ top: 120, behavior: 'smooth' })">
  Content Scroll to 120px
</n-button>
<n-layout style="height: 480px;">
  <n-layout-header style="height: 64px;"> Cool Header </n-layout-header>
  <n-layout position="absolute" style="top: 64px; bottom: 64px;">
    <n-layout-sider position="absolute" ref="sider" style="overflow: auto;">
      <n-h1>Long</n-h1><n-h1>Long</n-h1><n-h1>Long</n-h1> <n-h1>Long</n-h1
      ><n-h1>Long</n-h1><n-h1>Long</n-h1> <n-h1>Long</n-h1><n-h1>Long</n-h1
      ><n-h1>Long</n-h1> <n-h1>Long</n-h1><n-h1>Long</n-h1><n-h1>Long</n-h1>
    </n-layout-sider>
    <n-layout position="absolute" :native-scrollbar="false" ref="content">
      <n-h1>Long</n-h1><n-h1>Long</n-h1><n-h1>Long</n-h1> <n-h1>Long</n-h1
      ><n-h1>Long</n-h1><n-h1>Long</n-h1> <n-h1>Long</n-h1><n-h1>Long</n-h1
      ><n-h1>Long</n-h1> <n-h1>Long</n-h1><n-h1>Long</n-h1><n-h1>Long</n-h1>
    </n-layout>
  </n-layout>
  <n-layout-footer position="absolute" style="height: 64px">
    Cool Footer
  </n-layout-footer>
</n-layout>
.n-button {
  margin: 0 8px 12px 0;
}