I try to design card like items using React and tailwindcss. For different Layouts the exact same cards should show up in different sizes, keeping the perspective. Tailwind's scale feature does the scaling as I need. Unfortunately the height and width of the container does not adjust after scaling, instead the scaled item has some overflow. How can I set the containers height and width to the actual height and width including the overflow area?
Code example:
//file: Content.js
import React from 'react'
// Card-like box with some Content
const Content = () => {
return (
<div className="origin-top-left transform scale-125 border-2 w-28 m-1
border-blue-400 bg-gray-900 text-white">
<p>ABC</p>
<p>123</p>
</div>
)
}
export default Content
Then two of the Content Items are stacked up
//file: App.js
import './App.css';
import Content from './components/Content';
function App() {
return (
<>
<Content/>
<Content/>
</>
);
}
export default App;
Is
Items overlap after scaling up:
Expected
Items don't overlap after scaling up:
I want to know how to programatically set it to the correct height (and width), but not by manually figuring out specific margins or padding for each scale value.