我还是一个编程初学者,我正在做一个项目来提高知识。
我需要在图像顶部插入一个带有文本的 div,我正在尝试重新创建下图的示例:
div 的一半是图像,另一半是文本。你能告诉我该怎么做吗?
这是我放入codeandbox 的代码
import React from "react";
import "./styles.css";
export default function App() {
return (
<div className="App">
<h1>Restaurant</h1>
<div
style={{
display: "flex",
flexDirection: "column",
justifyContent: "baseline",
alignItems: "baseline",
height: "200px",
width: "100%",
maxWidth: "300px"
}}
>
<div>
<img
style={{
width: "100%",
height: "100%"
}}
src="https://b.zmtcdn.com/data/collections/271e593eb19475efc39021c6e92603db_1454591396.jpg"
alt=""
className="img"
/>
</div>
<div className="divText">
<span
style={{
color: "#fff",
backgroundColor: "#000"
}}
>
Lorem Ipsum! Lorem Ipsum! Lorem Ipsum!
</span>
</div>
</div>
</div>
);
}
30秒到达战场
天涯尽头无女友
宝慕林4294392
相关分类