Preserve Aspect Ratio Of An Element In Vue

Yet another Vue.js component to preserve the aspect ratio of an element no matter how you resize the viewport.

How to use it:

1. Import & register the component.

import Vue from "vue";
import VueAspectRatio from "vue-aspect-ratio";
export default {
  name: "AmazingComponent",
  props: [myprop],
  components: {
    "vue-aspect-ratio": VueAspectRatio
// or
Vue.component("vue-aspect-ratio", VueAspectRatio);

2. Create a new vue-aspect-ratio component in your template and specify the aspect ratio and initial width as follows:

<div class="my-container">
  <vue-aspect-ratio ar="4:3" width="480px">
    <div>Your Content Here</div>

Download Details:

Author: albertodeago

Live Demo:

Download Link:

Official Website:

Install & Download:

$ npm install vue-aspect-ratio --save

Add Comment