1 Star 0 Fork 0

羊开锦/myLove

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
list.html 4.51 KB
一键复制 编辑 原始数据 按行查看 历史
yang kai 提交于 2024-06-26 12:28 . 搭建
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>列表</title>
<link rel="stylesheet" href="./style/style.css">
<style>
.bigbox{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.list_box{
flex: 1;
overflow-y: auto;
}
.header{
height: 80rem;
width: 100%;
background-color: #DD3635;
display: flex;
align-items: center;
padding-left: 24rem;
padding-right: 24rem;
}
/* .search_box{
width: 57rem;
height: 57rem;
margin-left: 20rem;
} */
.nav{
flex: 1;
overflow-x: auto;
}
.nav ul{
display: flex;
align-items: flex-end;
}
.nav ul li{
color: #FFFFFF;
font-size: 36rem;
margin-right: 34rem;
flex-shrink: 0;
}
.nav ul li.sel{
font-size: 38rem;
font-weight: bold;
color: blue;
/* !important */
}
/* .search_box img{
width: 100%;
} */
.list_box{
padding: 24rem;
}
.list_box ul li{
display: flex;
justify-content: space-between;
height: 200rem;
border-bottom: 1px solid #a5a5a5;
padding-top: 20rem;
padding-bottom: 20rem;
}
.img_box{
width: 228rem;
height: 150rem;
overflow: hidden;
margin-left: 20rem;
}
.img_box>img{
/* width: 100%; */
width: 228rem;
height: 150rem;
}
.title_box{
display: inline-flex;
flex-direction: column;
justify-content: space-between;
}
.title{
color: #222222;
font-size: 34rem;
font-weight: 400;
text-align: justify;
height: 88rem;
overflow: hidden;
width: 454rem;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
text-overflow: ellipsis;
}
.time{
color: #A5A5A5;
font-size: 24rem;
}
</style>
</head>
<body>
<div class="bigbox">
<div class="header">
<div class="nav">
<ul>
</ul>
</div>
<div class="search_box">
<img src="./images/search.png" />
</div>
</div>
<div class="list_box">
<ul>
</ul>
</div>
<div class="foot_nav">3</div>
</div>
<script src="./js/ajax.js"></script>
<script>
// 渲染头部新闻分类菜单
var arr = ['军事','财经','NBA','汽车','文化','股票','时政'];
var navUl = document.querySelector('.nav ul');
var navHtml = '';
for(var i=0; i<arr.length; i++){
console.log(arr[i])
navHtml += '<li><a>'+arr[i]+'</a></li>'
}
// console.log(navUl)
navUl.innerHTML = navHtml
// 获取军事新闻列表并渲染
var listbox = document.querySelector('.list_box ul')
var listHtml = ``;
ajax({
url: '/news',
data: {
type: '军事'
},
success: function(res){
for(var i =0; i<res.length; i++){
// 时间处理
var d = new Date(parseInt(res[i].time))
listHtml += ` <li>
<div class="title_box">
<div class="title">${res[i].title}</div>
<div class="time">${res[i].source}-${res[i].type} &nbsp;&nbsp;&nbsp; ${d.getFullYear()}${d.getMonth()+1}${d.getDate()}日 </div>
</div>
<div class="img_box">
<img src="${res[i].img}" />
</div>
</li>`
}
listbox.innerHTML = listHtml;
}
})
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangkai-brocade/my-love.git
git@gitee.com:yangkai-brocade/my-love.git
yangkai-brocade
my-love
myLove
master

搜索帮助