search

Home  >  Q&A  >  body text

The title is rewritten as: Vuetify's v-img automatically adjusts according to the container size, not according to the src size

<p>Vuetify’s documentation about <code>v-img</code> is as follows: </p> <blockquote> <p>v-img will automatically resize itself based on the size of its src, maintaining the correct aspect ratio. You can limit the size using the height and max-height properties. </p> </blockquote> <p>However, it will automatically resize itself based on the size of the container or the size of <code>max-height</code>, whichever is smaller. It does not resize itself based on the size of the source file - in the example below, the image's src size is 256x256. </p> <p>Example: https://codepen.io/nullism/pen/bGWVreK</p> <p>Is this a bug in Veutify, or is there a problem with the documentation, or am I missing a property? </p> <p>Thank you very much for your help! </p> <p><strong>Update</strong>: It looks like the normal <code><img/></code> tag works as expected: https://codepen.io/nullism/pen /OJmyjvw</p>
P粉511896716P粉511896716497 days ago587

reply all(1)I'll reply

  • P粉790819727

    P粉7908197272023-08-26 00:43:01

    As far as I understand, you want the size of the image to be less than 256 x 256, then you can add the attribute max-width="256" max-heigth="256"

    <d id="app">
      <v-app id="inspire">
        <v-main>
          <v-container>
            <v-card>
              <v-card-text>
                <v-img max-width="256" max-heigth="256"
                  src="https://www.redditstatic.com/icon.png"
                ></v-img>
              </v-card-text>
            </v-card>
          </v-container>
        </v-main>
      </v-app>
    </div>

    reply
    0
  • Cancelreply