Vuetify v-menu dropdown is displayed in incorrect position when using css scale property
P粉983021177
P粉983021177 2024-03-19 18:55:15
0
1
378

As shown in the attached picture, the v menu position is in the wrong position when using the scale CSS property.

Corresponding codepen: https://codepen.io/satishvarada/pen/YzjGNVZ

Similar problems will also occur when using v-autocomplete components.

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    items: [{
        title: 'Click Me'
      },
      {
        title: 'Click Me'
      },
      {
        title: 'Click Me'
      },
      {
        title: 'Click Me 2'
      },
    ],
  }),
})
html {
  zoom: 40%
}
<link href="https://unpkg.com/[email protected]/dist/vuetify.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vuetify.min.js"></script>


<div id="app">
  <v-app id="inspire">
    <div class="text-center">
      <v-menu offset-y>
        <template v-slot:activator="{ on, attrs }">
          <v-btn
            color="primary"
            dark
            v-bind="attrs"
            v-on="on"
          >
            Dropdown
          </v-btn>
        </template>
        <v-list>
          <v-list-item v-for="(item, index) in items" :key="index">
            <v-list-item-title>{{ item.title }}</v-list-item-title>
          </v-list-item>
        </v-list>
      </v-menu>
    </div>
  </v-app>
</div>

P粉983021177
P粉983021177

reply all(1)
P粉693126115

One way is to use the left attribute, so the menu will always be on the left.

edit-

Another approach is to attach the menu to its parent element using the attach prop, so the component knows which DOM element it should detach to.

This is a demo with two props -

1. With scaling properties-

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    items: [{
        title: 'Click Me'
      },
      {
        title: 'Click Me'
      },
      {
        title: 'Click Me'
      },
      {
        title: 'Click Me 2'
      },
    ],
  }),
})
html {
  zoom: 40%
}
[email protected]/dist/vuetify.min.css" rel="stylesheet"/>



Using left prop
{{ item.title }}
Using attach prop
{{ item.title }}

2. No scaling attribute-

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    items: [{
        title: 'Click Me'
      },
      {
        title: 'Click Me'
      },
      {
        title: 'Click Me'
      },
      {
        title: 'Click Me 2'
      },
    ],
  }),
})
[email protected]/dist/vuetify.min.css" rel="stylesheet"/>



Using left prop
{{ item.title }}
Using attach prop
{{ item.title }}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template