So, my end goal is to make 'Card' component appear to be rectangle, rather than rounded.(因此,我的最终目标是使“卡片”组件看起来是矩形,而不是圆形。)
I'm looking for a way to pass a style down to img tag from react component(semantic-ui) "Card".(我正在寻找一种将样式从react component(semantic-ui)“ Card”传递给img标签的方法。) It seems like that the border radius of "Card"'s 'image' is non-zero.(似乎“卡”的“图像”的边界半径不为零。) I like it to be zero, so it has the 90 degree angles.(我喜欢它为零,所以它具有90度角。) Note that I'm able to modify "Card" component's border-radius without a problem.(请注意,我能够毫无问题地修改“卡”组件的边界半径。) What I want to know it to modify border-radius of the img inside of the "Card".(我想知道的是它可以修改“ Card”内部img的边框半径。)
import React from 'react'
import { Card } from 'semantic-ui-react'
function PhotoList({ photos }) {
const [displayPhotos, setDisplayPhotos] = React.useState(photos)
async function handleClick(idx) {
//some code...
}
function mapPhotosToItems(photos) {
return photos.map((photo, idx) => ({
// image: { src: photo.mediaUrl, style: 'border-radius:0' }, //tried.. doesn't work
// image: { src: photo.mediaUrl, style: { borderRadius: 0 } }, //tried.. doesn't work
image: { src: photo.mediaUrl },
style: { borderRadius: 0 }, //this makes Card's corners rectangle.
borderRadius: 0,
childKey: photo._id,
onClick: () => handleClick(idx)
}))
}
return <Card.Group stackable itemsPerRow={10} centered items={mapPhotosToItems(displayPhotos)}/>;
}
export default PhotoList
On chrome inspect, I was able to modify border-radius of img on the fly (the yellow box is what I added in chrome debugger), so I can get the desired result.(在chrome inspect上,我能够即时修改img的边界半径(黄色框是我在chrome调试器中添加的),因此我可以获得所需的结果。) But how do I pass the style from my code?(但是,如何从代码中传递样式?)
ask by Libertatem translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…