【发布时间】:2022-01-10 12:37:32
【问题描述】:
我是 ReactJS 的新手。我需要帮助将以下简单的 HTML/CSS 代码转换为 ReactJS。 我想在我的网站上有 3 个 CSS 卡,顶行 2 个位置,中间 1 个位置。请帮忙。
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width:40%;
height: 30%;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.container {
padding: 2px 16px;
}
<h2>Card</h2>
<div style="display: flex; justify-content: space-between; margin-top:100px; margin-right:150px; margin-left: 150px">
<div class="card">
<a href="https://www.google.com"><img src="https://wallpaperaccess.com/full/3856041.jpg" alt="Avatar"
style="width:100%"></a>
</div>
<div class="card">
<img src="https://wallpaperaccess.com/full/3856041.jpg" alt="Avatar" style="width:100%">
</div>
</div>
<div style="display: flex; justify-content: center; margin-top:100px; margin-right:150px; margin-left: 150px">
<div class="card">
<a href="https://www.google.com"><img src="https://wallpaperaccess.com/full/3856041.jpg" alt="Avatar"
style="width:100%"></a>
</div>
</div>
【问题讨论】:
-
您只需将
class重命名为className,而不是样式,您需要将其转换为对象。像这样:style = "display: flex; background-color: #000;"->style={{display: flex, backgroundColor: #000}}.
标签: javascript html css reactjs