You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.5 KiB

<!DOCTYPE html>
<html lang="zh">
<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>专题报道</title>
<link rel="stylesheet" href="css/foucsreport.css">
<link rel="stylesheet" href="css/common.css">
</head>
<body>
<div class="Progress">
<div class="Prostick"></div>
</div>
<div class="navbar">
<div class="navinit">
<div class="logo">web新闻网站</div>
<div class="navbtnpart">
<div class="navbtn"><a href="index.html">首页</a></div>
<div class="navbtn"><a href="newsclass.html">新闻分类</a></div>
<div class="navbtn"><a href="foucsreport.html">专题报道</a></div>
<div class="navbtn"><a href="newsinfo.html">新闻资讯</a></div>
<div class="navbtn"><a href="#">互动交流</a></div>
</div>
</div>
</div>
<div class="mainbody">
<div class="titlebar">
<div class="title">《专题报道》
<a href="#">更多>>></a>
</div>
</div>
<div class="reportbox">
<div class="boxtitle"></div>
<div class="boxcover"></div>
<div class="boxinfo"></div>
</div>
<div class="reportbox">
<div class="boxtitle"></div>
<div class="boxcover"></div>
<div class="boxinfo"></div>
</div>
<div class="reportbox">
<div class="boxtitle"></div>
<div class="boxcover"></div>
<div class="boxinfo"></div>
</div>
<div class="reportbox">
<div class="boxtitle"></div>
<div class="boxcover"></div>
<div class="boxinfo"></div>
</div>
<div class="reportbox">
<div class="boxtitle"></div>
<div class="boxcover"></div>
<div class="boxinfo"></div>
</div>
<div class="reportbox">
<div class="boxtitle"></div>
<div class="boxcover"></div>
<div class="boxinfo"></div>
</div>
</div>
<div class="footer">web新闻网站</div>
<script>
let totalHeight;
let Prostick;
document.addEventListener("DOMContentLoaded", function () {
let boxTitle = [
{ text: "新闻示例1" },
{ text: "新闻示例2" },
{ text: "新闻示例3" },
{ text: "新闻示例4" },
{ text: "新闻示例5" },
{ text: "新闻示例6" },
];
let boxCover = [
{ src: "path/to/image1.jpg" },
{ src: "path/to/image2.jpg" },
{ src: "path/to/image3.jpg" },
{ src: "path/to/image4.jpg" },
{ src: "path/to/image5.jpg" },
{ src: "path/to/image6.jpg" },
];
let boxInfo = [
{ text: "示例文本..." },
{ text: "示例文本..." },
{ text: "示例文本..." },
{ text: "示例文本..." },
{ text: "示例文本..." },
{ text: "示例文本..." },
];
const reportBoxes = document.querySelectorAll('.reportbox');
reportBoxes.forEach((box, index) => {
const boxTitleContent = box.querySelector('.boxtitle');
const boxCoverContent = box.querySelector('.boxcover');
const boxInfoContent = box.querySelector('.boxinfo');
const h3 = document.createElement('h3');
h3.textContent = boxTitle[index].text;
boxTitleContent.appendChild(h3);
const img = document.createElement('img');
img.src = boxCover[index].src;
boxCoverContent.appendChild(img);
const p = document.createElement('p');
p.textContent = boxInfo[index].text;
boxInfoContent.appendChild(p);
});
Prostick = document.querySelector('.Prostick');
totalHeight = document.body.scrollHeight - window.innerHeight;
});
window.addEventListener('scroll', function () {
let pro = (window.pageYOffset / totalHeight) * 100;
Prostick.style.width = pro + '%';
});
</script>
</body>
</html>