簡體   English   中英

我怎樣才能使我所有的圖片都具有相同的大小

[英]How I can make all my picture be on the same size

我試圖讓我的圖片在這里具有相同大小的不同分辨率,我嘗試了很多東西,但我不知道為什么它不起作用。 這是我https://prnt.sc/10qz5vk的結果,當我將 state 更改為 1、2、3 或 4 時,我想要在這里

 import React, { useState } from 'react' import './Styles/Slide.css' import { images } from './sliderojects'; function Slide() { const [currImage, setCurrImage] = useState(1); return ( <div className="slide-exterior"> <div className="slide-interior" style={{ backgroundImage: `url(${images[currImage].img})` }}> <img src={images[currImage].img} /> </div> </div> ) } export default Slide import room1 from './Media/room1.jpg'; import room2 from './Media/room2.jpg'; import room3 from './Media/room3.jpg'; import room4 from './Media/room4.jpg'; export const images = [ { title: "Brasov", subtitle: "This is the beatiful Brasov", img: room1 }, { title: "Iasi", subtitle: "Come to check our city Iasi", img: room2 }, { title: "Suceava", subtitle: "The haert of Bucovina - Suceava", img: room3 }, { title: "Bucuresti", subtitle: "Here you can see the biggest place is Romania", img: room4 }, ]
 .slide-exterior{ width: 70%; height: 500px; margin:auto; object-fit: cover; background-color: black; margin-top:20px; }.slide-interior{ width: 100%; height: 500px; object-fit: cover; background-position: 50% 50%; background-repeat: no-repeat; background-size: cover; display: flex; }

嘗試這個:
將 objectFit 屬性直接應用於標簽

<img src={images[currImage].img} style={{ width: '100%', height: '100%', objectFit: 'cover' }} />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM