When clicked, the size of a link will adjust

Having trouble with my code and CSS. The pagination in Vue is working fine, but the links are changing size on certain pages. When clicking on the first or second number, the links remain the same size. However, when clicking on the third or fourth link, the links suddenly get bigger. Any help is much appreciated!

<template>
  <h1>Pagination</h1>
  <div class="pagination">
    
  <a class="hover"  @mouseover="isHovering = true" @mouseout="isHovering = false"  @click="changePageToParent(1); changePage(1);">First</a>
    <a class="hover" v-if="totalPage<=5"> <a class="hover" @mouseover="isHovering = true" @mouseout="isHovering = false" v-for="item in 5" v-bind:key="item" @click="changePageToParent(item); changePage(item)"> {{ item }} </a></a>

  <a v-else class="hover">
  <a v-if="lijeviOffset>=2" class="hover" >...</a> 

      <a class="hover" @mouseover="isHovering = true" @mouseout="isHovering = false" v-for="item in 5" v-bind:key="item" @click="changePageToParent(item); changePage(item)">
        <a class="hover" v-if="currentPage == 2">  {{ item+offset+1 }}  </a> 
        <a class="hover" v-else-if="currentPage == 1"> {{ item+offset+2 }}</a> 
                    <a class="hover" v-else>
                    <a class="hover" v-if="desniOffset == 8"> {{ item + 2 }} </a>  
                    <a class="hover" v-else-if="desniOffset == 9"> {{ item + 2}} </a>
                    <a class="hover" v-else>{{ item+offset }}</a>  
                    </a> 
      </a> 
        <a v-if="provjera" class="hover">...</a>
    </a>
  <a class="hover" @mouseover="isHovering = true" @mouseout="isHovering = false" @click="changePageToParent(totalPage); changePage(totalPage)">Last</a> 
 
 </div>
</template>
<script>
export default {
  name: 'Pag',
  data() {
    return {
      currentPage: 1,
      da: null,
      totalPage:7,
      perPage: 2,
      isHovering: false,
      isActive: false,

    }
  },
  props:  {
  total: Number,
  }, computed: {
    offset: function(){
    return this.currentPage-this.perPage-1;
    },
    provjera: function(){
          return this.currentPage+this.perPage<this.totalPage ? 1 : null
    },
    desniOffset: function () {
      return this.currentPage+this.perPage;
    },
    lijeviOffset: function () {
      return this.currentPage-this.perPage;
    },
  }, methods: {
    changePageToParent(id) {
      this.$emit('change-page-to-parent', id)
    },
    changePage(id) {
      this.currentPage = id
    },
    hoverToggle(subjectId, action){
    switch(action){
        case 'mouseOver':
            return this.hoveredSubjectId = subjectId;
        case 'mouseLeave':
            return this.hoveredSubjectId = "";
    }
  },
  toggleClass() {
          this.isActive = !this.isActive;
  }
  }
}
</script>
<style scoped>

body {
    color: blue;
}

.pagination {
  width:0 auto;
}

.hover a {
  margin:5px;
  background-color: red;
}



</style>

Answer №1

Do you have a specific rationale for incorporating a "hover" class rather than utilizing the pseudo-class :hover?

Upon clicking three or four times, do the links increase in size when in their default state, on hover, or on click?

If the enlargement occurs on click, it is recommended to apply styling using the :active pseudo-class. Be mindful to arrange your pseudo-classes in this sequence to avoid conflicts: :link, :visited, :hover, :focus, :active.

Edit: Refer to the image below for clarification on my earlier comment: https://i.sstatic.net/s2s9E.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the method to utilize Vue $refs within a plugin

methods: { async create () { this.disableSubmit = true; await this.$firestore .collection('collectionName') .add(this.item) .then(() => { this.$refs.createForm.reset(); this.$notify('positive& ...

Dynamic horizontal scrolling

I need help implementing a site using React that scrolls horizontally. I'm unsure how to implement certain aspects, so I am looking for some assistance. Within a wrapper, I have multiple container Divs. <div class="wrapper"> <div class=" ...

Encountering challenges with integrating GraphQL and the Magic API. Seeking guidance on implementing mutations and queries on a server to establish a schema

In my project, I have organized my GraphQL operations into two separate files: mutations.js and queries.js, which are stored in a directory named gql... The gql folder serves as a repository for GraphQL mutations and queries that are utilized throughout t ...

Tips for positioning a div relative to another div while controlling its z-index

Hey there, take a look at the image below https://i.sstatic.net/zYiaY.png The issue I'm facing is quite common - I have div 1 and div 2 visible in a loop, but divs 3 are hidden. When div 2 is clicked on, everything is great so far. However, what I wa ...

What is the best way to make the chips within a disabled v-select interactive?

I am facing an issue with a v-select element in Vue.js that uses v-chips to represent selected items. I want the chips to act as buttons when not editing the selection, but the v-select is disabled in non-editing mode. Unfortunately, due to disabling the v ...

Why is it that the LESS compiler fails to recognize classes that are created by a zero iterator

When working with my CSS sheet, I found that I needed to reset some Bootstrap 3 preset values in order to achieve my desired style. To do this, I started using utility classes like .m-b-0 which sets margin-bottom:0px. However, I encountered an issue with ...

Variable in SCSS not being applied as expected

I'm currently grappling with understanding why my alterations to the system colors aren't reflecting as expected. When viewing in Chrome, this is the image I see. https://i.sstatic.net/H6YbW.png However, this is what I anticipate should be vis ...

What is the best way to expand the navigation bar: should I add a side div or incorporate a background image?

I am encountering two issues that I need help solving. My first problem involves stretching out the navigation bar to fill the height and length of the adjacent div (div#textarea) while also keeping the text of the menu centered within that div. The seco ...

experimenting with encoding an image in base64 and implementing it

After coming across a block of code online, I've encountered a situation where it seems to be functioning and malfunctioning simultaneously. It's quite possible that my lack of comprehension is the root cause, as I'm struggling to make it wo ...

The VueJS Watcher fails to activate when monitoring changes within nested objects

I have created a codesandbox to demonstrate my issue: codesandbox example watcher not triggering. Currently, I am developing a component that depends on an object with dynamically added data. In a separate .js file, I export the following object: export d ...

Nuxt fetch() function being invoked numerous times in succession

I have been working on a base component that receives an image from an Array.Buffer asynchronously. When following the Nuxt documentation, I initially used fetch() but it ended up getting called more than 20 times. Why is this happening? Should I stick to ...

Arrange two input fields side by side if the quantity of input fields is unspecified

I am currently in the process of developing a project using Angular. I have implemented an *ngFor loop to dynamically add input fields based on the data retrieved from the backend. Is there a way I can ensure that two input fields are displayed on the same ...

Using Vue.js to create a bidirectional binding between two input fields

I'm diving into vue.js for the first time and I've come across an issue. I want to create a scenario where C = A - B, and B = A - C. A is constant and any change in B or C should affect the other. While I successfully bound C using v-model and ...

Tips for maintaining video playback in HTML5 when the video element is clicked

I am currently working on creating a straightforward video conference setup and I specifically want to only allow the fullscreen feature when sharing the video element. I also want to disable all other controls such as volume, mute, seek, play, pause, and ...

CSS text width going from left to right

I am attempting to create a text fade effect from left to right, inspired by the technique discussed in this answer. However, I would like the text to be concealed behind a transparent background div instead of the white background used in the example. I ...

Exploring VueJS: Extracting nested object values from the Vuex store

I'm encountering an issue accessing a nested property of the store state data that returns as undefined when I attempt to access it. Here is the data I am working with: const state = { entity: { initial: {valid: false}, general: {valid: fals ...

Placing a dynamic loading image in the center of a webpage

Positioning an ajax loading image in the center of a mobile page. The code snippet above is used to load database records via ajax by displaying a loading image in a Div element. My inquiry is regarding how to ensure that this loading image appears at th ...

Incorporating CSS styles into a dynamic JavaScript computation

I'm attempting to apply inline CSS to a JS calculation (e.g. 3*2*1) in order to make it appear red. I have experimented with using a span tag, but it only displays the calculation and not the result. I also tried utilizing an internal style sheet. Ho ...

Utilizing CSS background sizing with jQuery for stunning website aesthetics

In my HTML file, there is a main div container with two nested divs inside it. Each of these inner divs has been assigned separate ids for content placement. By implementing a functionality that changes the background image of the parent div upon clicking ...

Hyperlinking Github.io Images

I'm facing an issue regarding image paths on github.io. It seems like the images from my github repository are not displaying properly (I made sure to check spelling and case sensitivity). I'm running out of ideas, so maybe you can help me spot m ...