我有一個作品集頁面,其中包含一個網格,其中包含帶有信息疊加的圖像。這是鏈接:cyrilmoisson-dev.netlify.app有沒有一種解決方案可以使覆蓋 div 的大?。ǜ叨群蛯挾龋┡c圖像完全相同,而不使用類似的東西background: url(...); 問題是圖像是隨機大小的......這個問題不是這個問題的重復,因為它還沒有為我解決。這是每個圖像的組件代碼:src/component/ImageWithInfos/ImageWithInfos.jsx:// Lazyloadimport LazyLoad from 'react-lazyload';// Styleimport { ImageContainer, ImageSrc, ImageInfoContainer, ImageInfo } from './styles';// Utilsimport PropTypes from 'prop-types';import { v4 as uuid } from 'uuid';const ImageWithInfos = ({ height, width, src, title, infos }) => ( <LazyLoad height={height} offset={height + 100}> <ImageContainer height={height} width={width}> <ImageSrc src={src} alt={title} /> <ImageInfoContainer> <ImageInfo main>{title}</ImageInfo> {infos.map((info) => <ImageInfo key={uuid()}>{info}</ImageInfo>)} </ImageInfoContainer> </ImageContainer> </LazyLoad>);ImageWithInfos.propTypes = { height: PropTypes.number.isRequired, width: PropTypes.number.isRequired, src: PropTypes.string.isRequired, title: PropTypes.string.isRequired, infos: PropTypes.array,};export default ImageWithInfos;src/component/ImageWithInfos/index.jsexport { default } from './ImageWithInfos';感謝您的幫助。順便說一句:我正在使用反應和樣式組件,如果它改變了什么......
如何相對于圖像定位 div?
瀟瀟雨雨
2024-01-18 15:50:47