search

Home  >  Q&A  >  body text

Vuetify v-menu dropdown is displayed in incorrect position when using css scale property

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粉983021177P粉983021177251 days ago379

reply all(1)I'll reply

  • P粉693126115

    P粉6931261152024-03-20 16:27:36

    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 }}

    reply
    0
  • Cancelreply