Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
How to go automatically at the bottom of a page without scrolling down when a new div appears in Vue application styled with Tailwind?

In my Nuxt/Vue application with Tailwind, by clicking on one element I am uncovering the next element. It works fine but the user needs to scroll down to see the new element. How can I make my app to go straight away to the bottom of the page to see the new element without scrolling down ??

<template>
  <div @click="onClick">
    <Element/>
  </div>
  <div v-if="Section > 0" @click="onClick">
    <Element/>
  </div>
  <div v-if="Section > 1" @click="onClick">
    <Element/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      Section: 0
    }
  },
  methods: {
    onClick() {
      this.Section++
    }
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do it by referencing the divs and then using window.scrollTo to scroll to them (or at the bottom of the page).

Just an example of how you can do it (your code modified):

<template>
  <div @click="onClick('section0')" ref="section">
    <Element/>
  </div>
  <div v-if="Section > 0" ref="section0" @click="onClick('section1')">
    <Element/>
  </div>
  <div v-if="Section > 1" ref="section1" @click="onClick('nextSectionRef')">
    <Element/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      Section: 0
    }
  },
  methods: {
    onClick(refName) {
      this.Section++;

      var element = this.$refs[refName];
      var top = element.offsetTop;

      window.scrollTo(0, top);
    }
</script>

This will help you to understand it better: https://shouts.dev/vuejs-scroll-to-elements-on-the-page

This also might answer your question: Scroll to bottom of div with Vue.js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!