<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title>公益积分榜</title>
<script src="https://cdn.suoluomei.com/common/js/jquery-2.1.4.min.js"></script>
<style>
body {
background-color: #F3F2F7;
}
.list {
width: 95%;
border-radius: 0.5rem;
background-color: white;
margin: 1rem auto;
}
.list_top {
display: flex;
justify-content: space-around;
}
.ranking {
width: 25%;
height: 5rem;
display: flex;
align-items: center;
justify-content: center;
}
.ranking_img {
width: 4rem;
height: 4rem;
border-radius: 50%;
}
.ranking_p {
width: 25%;
margin: auto;
text-align: center;
}
.abx {
width: 25%;
margin: auto;
text-align: center;
}
.portrait {
width: 4rem;
height: 4rem;
border-radius: 50%;
}
.list_top_p {
width: 25%;
margin: auto;
text-align: center;
}
.integral {
width: 25%;
margin: auto;
text-align: center;
}
.rol {
background: url("https://sucai.suoluomei.cn/sucai_zs/images/20191123133534-first.png");
background-size: 100% 100%;
}
.roltwo {
background: url("https://sucai.suoluomei.cn/sucai_zs/images/20191123133548-Second.png");
background-size: 100% 100%;
}
.rolthree {
background: url("https://sucai.suoluomei.cn/sucai_zs/images/20191123133558-Third.png");
background-size: 100% 100%;
}
</style>
</head>
<body>
<div class="srceen">
<div class="list">
<div id="row">
<div class="list_top">
<div class="ranking rol">
<p class="ranking_p"></p>
</div>
<div class="ranking"><img class="portrait" src="" alt=""></div>
<p class="list_top_p"></p>
<p class="integral"></p>
</div>
<div class="list_top">
<div class="ranking roltwo">
<p class="ranking_p"></p>
</div>
<div class="ranking"><img class="portrait aaaa" src="" alt=""></div>
<p class="list_top_p bbbbb"></p>
<p class="integral cccc"></p>
</div>
<div class="list_top">
<div class="ranking rolthree">
<p class="ranking_p"></p>
</div>
<div class="ranking"><img class="portrait fff" src="" alt=""></div>
<p class="list_top_p ggg"></p>
<p class="integral hhh"></p>
</div>
<div id="xiabu">
</div>
</div>
</div>
</div>
</body>
<script>
var daya = [{
ranking: "1",
portrait: "https://sucai.suoluomei.cn/sucai_zs/images/touxiang.jpeg?x-oss-process=image/resize,p_25,limit_0",
name: "赵云",
integral: "23554"
},
{
ranking: "2",
portrait: "https://sucai.suoluomei.cn/sucai_zs/images/touxiang.jpeg?x-oss-process=image/resize,p_25,limit_0",
name: "关羽",
integral: "22535"
},
{
ranking: "3",
portrait: "https://sucai.suoluomei.cn/sucai_zs/images/touxiang.jpeg?x-oss-process=image/resize,p_25,limit_0",
name: "张飞",
integral: "21535"
},
{
ranking: "4",
portrait: "https://sucai.suoluomei.cn/sucai_zs/images/touxiang.jpeg?x-oss-process=image/resize,p_25,limit_0",
name: "小码",
integral: "21535"
},
{
ranking: "5",
portrait: "https://sucai.suoluomei.cn/sucai_zs/images/touxiang.jpeg?x-oss-process=image/resize,p_25,limit_0",
name: "茄子",
integral: "21535"
},
{
ranking: "6",
portrait: "https://sucai.suoluomei.cn/sucai_zs/images/touxiang.jpeg?x-oss-process=image/resize,p_25,limit_0",
name: "葡萄",
integral: "21535"
}
]
let data = daya
// console.log(data[0])
$('.portrait').attr("src", data[0].portrait)
$('.list_top_p').html(data[0].name)
$('.integral').html(data[0].integral)
$('.aaaa ').attr("src", data[1].portrait)
$('.bbbbb').html(data[1].name)
$('.cccc ').html(data[1].integral)
$('.fff').attr("src", data[2].portrait)
$('.ggg').html(data[2].name)
$('.hhh').html(data[2].integral)
console.log(data.slice(3, 999))
var items = ''
for (let i = 3; i < data.length; i++) {
items += `
<div class="list_top">
<div class="ranking"><p class="abx">${data[i].ranking}</p></div>
<div class="ranking"><img class="portrait" src="${data[i].portrait}" alt=""></div>
<p class="list_top_p">${data[i].name}</p>
<p class="list_top_p">${data[i].integral}</p>
</div>
`
}
$('#xiabu').append(items)
</script>
</html>
来源:CSDN
作者:hql1024
链接:https://blog.csdn.net/hql1024/article/details/103214100