【发布时间】:2020-12-08 13:41:11
【问题描述】:
我正在尝试在我的 React 应用程序的视频卡中使用上传图标的背景图像,但到目前为止还无法显示背景图像。我看到了我声明的背景颜色,但没有看到背景图像,我不知道为什么。以下是相关代码块:
<Card.Section
fill
styles={{
...backgroundImageCardSectionStyles,
root: {
...backgroundImageCardSectionStyles.root,
backgroundImage: '../../assets/images/upload.png',
backgroundColor: '#f3f2f1',
minHeight: '150px',
maxHeight: '150px',
},
}}
... more code
我也试过拉图标是一个导入,像这样:
import { uploadIcon } from '../../assets/images/upload.png';
...然后像这样使用它:
<Card.Section
fill
styles={{
...backgroundImageCardSectionStyles,
root: {
...backgroundImageCardSectionStyles.root,
backgroundImage: uploadIcon,
backgroundColor: '#f3f2f1',
minHeight: '150px',
maxHeight: '150px',
},
}}
... more code
但这也没有用。
顺便说一下,我上面引用的backgroundImageCardSectionStyles 是这样的:
const backgroundImageCardSectionStyles = {
root: {
backgroundPosition: 'center center',
backgroundSize: 'cover',
height: 144,
},
};
我在这里错过了什么?
【问题讨论】:
标签: css reactjs icons background-image fluent-ui