Closed ignacio-dev closed 2 years ago
for background image, AspectRatio should be your container of the background image div
https://roderickhsiao.github.io/react-aspect-ratio/?path=/story/aspect-ratio--background-image
import { AspectRatio } from 'react-aspect-ratio';
<AspectRatio
ratio="4/5"
style={{
maxWidth: '600px',
}}
>
<div
style={{
backgroundImage: 'url(https://c1.staticflickr.com/4/3896/14550191836_cc0675d906.jpg)',
backgroundSize: 'cover'
}}
/>
</AspectRatio>
Importing the CSS file solved the issue:
import 'react-aspect-ratio/aspect-ratio.css';
Thank you!
Awesome!
The following code won't work:
This is the resulting output:
But it just gets render like a regular div...
None of the examples provided work either! The package is properly installed. What am I missing?