就是一个列表啊 ,用不到二维数组吧 。 一个 数组里 加对象 就行
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
list-style: none;
width: 100%;
}
.list {
width: 100%;
}
li {
/* width: 100%; */
height: 80px;
background: gainsboro;
display: flex;
border: 1px solid red;
margin: 10px 0px;
}
li>.left>img {
width: 80px;
height: 80px;
}
.right {
margin: 10px 10px 10px 20px;
}
.right>span {
font-size: 25px;
font-weight: 800;
}
.right>p {
width: 220px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
margin-top: 5px;
}
</style>
</head>
<body>
<div class="list">
<ul id="box">
<li>
<div class="left">
<img src="https://img2.baidu.com/it/u=3007239063,3286115021&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=693"
alt="">
</div>
<div class="right">
<span>田曦薇</span>
<p>
田曦薇,1997年10月14日出生于重庆市,毕业于上海戏剧学院,中国内地女演员
</p>
</div>
</li>
</ul>
</div>
</body>
<script>
let arr = [
{
picture: "https://img2.baidu.com/it/u=3007239063,3286115021&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=693",
name: "田曦薇",
introduce: "田曦薇,1997年10月14日出生于重庆市,毕业于上海戏剧学院,中国内地女演员"
},
{
picture: "https://img2.baidu.com/it/u=3007239063,3286115021&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=693",
name: "小田",
introduce: "田曦薇,1997年10月14日出生于重庆市,毕业于上海戏剧学院,中国内地女演员"
}
];
let box = document.getElementById("box");
let str = "";
arr.map((item) => {
str += `<li>
<div class="left">
<img src="${item.picture}"
alt="">
</div>
<div class="right">
<span>${item.name}</span>
<p>
${item.introduce}
</p>
</div>
</li>`
});
box.innerHTML=str;
</script>
</html>