Parent element scales and fits child element (React)

Demo

This is a React/Next.js demo project which shows how you can scale child element in parent to fit vertically or horizontally. The resize happens on windo resize event.

Refer page/index.tsx and page/index.module.css to see parent and child styles and hooks/useChildScaleToFirParent.ts to understand the logic of scaling for different orientaion combinations for both parent and child.

Demo here.

GitHub

View Github