我是样式设计的新手,如果这太基础了,对不起。
在我的React应用程序中,我试图从文件中导入图像,如下所示:
import cup from './img/cup.png'
并将其与文本以及其中包含的所有其他内容一起设置样式,<div>
如下所示:
<div style={{display:'inline-block',
textDecoration:'underline',
cursor:'pointer'}}>
<img src={cup} alt=''/>
<h1 className="title is-4">"Item"</h1>
</div>
但这很糟糕。图像显示太大。
我想直接参考图像style
并在其中管理“高度”和“宽度”(或“大小”),但是还没有找到方法。
这可能吗?为何如此?
如果您想垂直尝试
<div>
<div style={{ display: "inline-block",
textDecoration: "underline",cursor: "pointer"}}>
<img
style={{ height: 100 }} src={
"https://www.belightsoft.com/products/imagetricks/img/[email protected]"
} alt=""
/>
<h1 className="title is-4">"Item"</h1>
</div>
</div>
如果你想水平
<div>
<div style={{ display: "flex", textDecoration: "underline", cursor: "pointer"}}>
<img style={{ height: 100 }} src={
"https://www.belightsoft.com/products/imagetricks/img/[email protected]"
} alt=""
/>
<h1 className="title is-4">"Item"</h1>
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句