Following the create-react-app doc, I imported a svg as a react component.
However, I can't seem to resize or position it properly, whether it's inline or through css.
I want to scale the SVG component to the same size as my other icon of 100px by 100px, then position at the bottom center of the screen.
I tried setting a width and height props for the svg component.
<IconClose
className="bubbleBin"
alt="close bubble"
height="100px"
width="100px"
// viewBox="0 0 100 100"
/>
and in css.
.bubbleBin {
display: flex;
position: absolute;
pointer-events: none;
align-items: center;
align-self: center;
justify-content: flex-end;
}
Here's the minimal code to reproduce it. Full code in Sandbox if needed.
...
import { ReactComponent as IconClose } from './assets/icon_close.svg';
function App() {
const ICON_WIDTH = 100;
const ICON_HEIGHT = 100;
return (
<div style={{ display: 'flex' }}>
<img
src={require('./assets/cat_icon.png')}
width={String(ICON_WIDTH)}
height={String(ICON_HEIGHT)}
alt="cat icon"
draggable={false}
/>
<IconClose
className="bubbleBin"
alt="close bubble"
height="100px"
width="100px"
/>
</div>
);
}
I expect the svg to be the same size as my cat icon but this is the result instead.
Thank you.