1.0.4 • Published 4 years ago

vue-image-ratio v1.0.4

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

Vue-image-ratio

Small Vue.js component using a CSS padding-bottom hack for 16/9 images.

Compatibility

Vue VersionSupport
2.x
3.x

Installation

npm i vue-image-ratio --save

The component

The component can be use like so:

<template>
  <vue-image-ratio
    :attrs="{
      src: 'https://doge.com/doge.png',
      alt: 'Doge',
      class: 'rounded'
    }"
  >
    <figcaption>Doge</figcaption>
  </vue-image-ratio>
</template>

<script>
import VueImageRatio from 'vue-image-ratio'

export default {
  ...,
  components: {
    ...,
    VueImageRatio
  }
}
</script>

Props

PropTypeDescriptionDefault
attrsObjectAn object repesenting the HTML attributes of the <img> element{ src: '...', alt: ''}
coverBooleanIf the <img> should be set to object-fit: cover;true

Slot

The component has a default <slot> that can be used to place content inside of the <figure>, under the <img>.

CSS classes

Each of theses classes are prefixed with vue-image-ratio-

Name
image-container
figure
img
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago