效果:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--引进css-->
<link rel="stylesheet" href="index.css" />
</head>
<body>
<!------------------------------header---------------------------------->
<div class="header">
<div>
下蛋中的战斗鸡
</div>
<ul id="menu">
<li>MENU</li>
</ul>
<input type="button" value="切换颜色" />
</div>
<!------------------------------侧边导航栏-------------------------------------->
<div id="side_nave">
<span>关闭侧边栏</span>
</div>
<!------------------------------版本导航栏-------------------------------------->
<div id="edition" class="container">
<ul>
<li>Visual Studio 2019 Enterprise</li>
<li>BF8Y8-GN2QH-T84XB-QVY3B-RC4DF</li>
<li>Visual Studio 2019 Professional</li>
<li>NYWVH-HT4XC-R2WYW-9Y3CM-X4V3Y</li>
</ul>
</div>
<!------------------------------作者信息模块-------------------------------------->
<h3>··读完了喵喵··</h3>
<div id="writer" class="container">
<table>
<tr>
<td>
作 者:
</td>
<td>
<a href="#">百思不得姐</a>
</td>
</tr>
<tr>
<td>
出 处:
</td>
<td>
<a href="#">https://www.zijixiedaima.com</a>
</td>
</tr>
<tr>
<td>
关于博主:
</td>
<td>
美女
</td>
</tr>
<tr>
<td>
版权声明:
</td>
<td>
署名-非商业性使用-禁止演绎,<a href="#">协议普通文本</a>|<a href="#">协议法律文本</a>
</td>
</tr>
<tr>
<td>
声援博主:
</td>
<td>
如果您觉得文章管用,可以点击文章右下角<span>【</span><a href="#" class="tuijian">推荐</a><span>】</span>。您的鼓励是博主最大的动力!
</td>
</tr>
</table>
</div>
<!------------------------------分类模块------------------------------------------>
<div id="fenlei" class="container">
<table>
<tr>
<td>
分类:
</td>
<td>
<a href="#">碎片代码</a>
</td>
</tr>
</table>
</div>
<!------------------------------分享模块-------------------------------------->
<div id="share" class="container">
<ul>
<li class="one">好文要顶</li>
<li class="two"><a href="#">关注我</a></li>
<li class="three"><a href="#">收藏该文</a></li>
<li class="four"><a href="#">分享到微博</a></li>
<li class="five"><a href="#">分享到微信</a></li>
</ul>
</div>
<!------------------------------文章点赞收藏-------------------------------------->
<div id="artical" class="container">
<div>
<span></span>
<ul class="massage">
<li><a href="#">百思不得姐</a></li>
<li><a href="#">关注-2</a></li>
<li><a href="#">粉丝-73</a></li>
<li><a href="#">+关注</a></li>
</ul>
</div>
<div class="recommend_top">0</div>
<div class="recommend_bott">推荐</div>
<div class="oppose_top">0</div>
<div class="oppose_bott">反对</div>
<table>
<tr>
<td><a href="#"><<</a>上一篇:</td>
<td><a href="#">https://www.zijixiedaima.html</a></td>
</tr>
<tr>
<td><a href="#">>></a>下一篇:</td>
<td><a href="#">https://www.zijixiedaima.html</a></td>
</tr>
</table>
<ul class="shuaxin">
<li class="pinglun"><a href="#">刷新页面</a></li>
<li class="yemian"><a href="#">刷新评论</a></li>
<li class="dingbu"><a href="#">返回顶部</a></li>
</ul>
</div>
<!------------------------------历史文章跳转-------------------------------------->
<div class="container" id="history">
<p>历史上的今天:</p>
<table>
<tr>
<td>2017-04-04</td>
<td><a href="#">Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) E</a></td>
</tr>
<tr>
<td>2017-04-04</td>
<td><a href="#">Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) D</a></td>
</tr>
<tr>
<td>2017-04-04</td>
<td><a href="#">Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) C</a></td>
</tr>
<tr>
<td>2017-04-04</td>
<td><a href="#">Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) B</a></td>
</tr>
<tr>
<td>2017-04-04</td>
<td><a href="#">Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) A</a></td>
</tr>
</table>
<div class="img">
</div>
</div>
<!------------------------------底部-------------------------------------->
<div id="bottom">
<ul>
<li>美少女 ©2019 百思不得姐</li>
<li>【小哥哥>3<小姐姐】</li>
<li>This blog will running : forever</li>
<li>友情链接:<a href="#">申请坑位</a></li>
</ul>
</div>
<script src="index.js"></script>
</body>
</html>
CSS:
*{
margin: 0;
padding: 0;
}
/*版心*/
.container{
width: 1000px;
margin: 0 auto;
}
li{
list-style: none;
}
a{
text-decoration: none;
color: cadetblue;
}
/*------------------------header-----------------------------*/
.header{
height: 300px;
background-image: url("images/2.gif") ;
border-bottom: #cccccc dotted 1px;
overflow: hidden;
position: relative;
}
.header div{
width: 600px;
height: 100px;
/*background-color: deeppink;*/
margin: 100px auto 100px;
color: black;
text-align: center;
font: normal 700 60px "宋体";
line-height: 100px;
}
.header ul{
position: absolute;
left: 20px;
top: 20px;
width: 50px;
height: 30px;
/*background-color: cadetblue;*/
border: aliceblue 1px solid;
line-height: 30px;
}
.header ul li{
width: 30px;
height: 15px;
float: left;
cursor: pointer;
}
/*header改变背景颜色*/
.header input{
position: absolute;
right: 10px;
top: 10px;
background-color: #ccc;
outline: 0;
}
/*----------------------------侧边导航栏----------------------------*/
#side_nave{
width: 200px;
height: 1000px;
background-color: black;
position: absolute;
left: 0;
top: 0;
display: none;
}
/*侧边栏关闭按钮*/
#side_nave span{
border: white solid 1px;
float: right;
font: normal 700 16px "宋体";
margin-top: 5px;
margin-right: 5px;
color: azure;
cursor: pointer;
}
/*----------------------------版本导航栏----------------------------*/
#edition{
height: 200px;
/*background-color: aqua;*/
}
#edition ul li{
font: normal 700 18px "宋体";
height: 50px;
width: 400px;
text-align: left;/*文字左端对齐*/
line-height: 50px;
margin: auto;/*盒子水平居中*/
cursor: text;
}
/*----------------------------作者信息模块----------------------------*/
h3{
margin: 60px auto 20px;
text-align: center;
color: darksalmon;
}
#writer{
height: 200px;
width: 900px;
/*background-color: gainsboro;*/
/*margin-top: 100px;*/
padding-left: 100px;
border:#ccc solid 1px;
background: rgba(0,0,1,0.1);
}
#writer table tr{
font: normal 400 18px "宋体";
height: 40px;
line-height: 40px;
cursor: text;
}
#writer table tr span{
color: red;
}
#writer .tuijian{
font-weight: 700;
}
/*----------------------------分类模块----------------------------*/
#fenlei{
width: 900px;
height: 40px;
/*background-color: red;*/
line-height: 40px;
padding-left: 100px;
margin-top: 20px;
}
#fenlei table tr a{
display: block;
width: 120px;
height: 30px;
background-color: #cccccc;
border:#ccc solid 1px;
border-radius: 30%;
text-align: center;
line-height: 30px;
}
#fenlei table tr a:hover{
background-color: lightsalmon;
color: azure;
}
/*----------------------------分享模块----------------------------*/
#share{
height: 100px;
margin-top: 20px;
border-top: #cccccc dashed 1px;
border-bottom: #cccccc dashed 1px;
}
#share ul{
width: 800px;
margin: 40px auto 0;
}
#share ul li{
float: left;
margin-left: 40px ;
width: 100px;
height: 40px;
text-align: center;
line-height: 40px;
color: white;
border-radius: 10%;
}
#share ul li a{
color:white;
}
#share .one{
background-color: cadetblue;
}
#share .two{
background-color: red;
}
#share .three{
background-color: yellow;
}
#share .four{
background-color: deeppink;
}
#share .five{
background-color: green;
}
#share ul li:hover{
box-shadow: 0px 5px 2px 2px rgba(0,0,0,0.1);
border:#ccc solid 1px;
cursor: pointer;
}
/*----------------------------文章点赞收藏----------------------------*/
#artical{
height: 250px;
width: 970px;
/*border:#ccc solid 1px;*/
margin-top: 20px;
padding: 0;
position: relative;
padding-left: 30px;
}
#artical span{
width: 100px;
height: 100px;
display: inline-block;
background-color: deeppink;
border-radius:50%;
}
#artical .massage{
display: inline-block;
margin-left: 20px;
margin-top: 0;
}
#artical .massage li{
margin-top: 6px;
}
#artical .recommend_top,
.oppose_top{
position: absolute;
height:30px;
width: 50px;
background-color: lightsalmon;
text-align: center;
line-height: 30px;
cursor: pointer;
border-radius: 10%;
color: cadetblue;
}
#artical .recommend_top{
right:90px;
top:20px;
}
#artical .oppose_top{
right: 20px;
top: 20px;
}
#artical .recommend_bott,
.oppose_bott{
position: absolute;
height:20px;
width: 50px;
background-color: #ccc;
text-align: center;
line-height: 20px;
cursor: pointer;
font: normal 400 14px "宋体";
}
#artical .recommend_bott{
right:90px;
top:50px;
color: blue;
}
#artical .oppose_bott{
right: 20px;
top: 50px;
}
#artical table {
margin-top: 20px;
}
#artical table tr{
height: 30px;
}
#artical .shuaxin{
position: absolute;
height: 30px;
display: block;
right: 1px;
bottom:5px;
}
#artical .shuaxin li{
float: left;
margin-right: 19px;
font: normal 400 14px "宋体";
}
/*----------------------------历史文章跳转----------------------------*/
#history{
height: 410px;
width: 960px;
/*background-color: lightsalmon;*/
margin-top: 20px;
padding-top: 20px;
padding-left: 40px;
}
#history table{
margin-top: 20px;
}
#history table tr{
height: 30px;
}
#history .img{
height: 200px;
background: url("images/3.gif") no-repeat ;
}
/*----------------------------底部---------------------------*/
#bottom{
height: 200px;
background-color: black;
/*margin-top: 300px;*/
padding-top: 20px;
}
#bottom ul{
width: 600px;
margin: 20px auto 0;
}
#bottom ul li{
font-size: 12px;
height: 30px;
color:darkgray;
margin-top: 10px;
text-align: center;
line-height: 30px;
}
JS:
// 寻找id函数
function getId(id) {
return document.getElementById(id);
}
// -----------------------header改变背景颜色,没用--------------------------------
// ------------------------侧边栏menu设置---------------------------------
getId("menu").onmouseover=function () {
this.style.border="red solid 1px";
};
getId("menu").onmouseout=function () {
this.style.border="";
};
getId("menu").onclick=function () {
if(getId("side_nave").style.display=="block"){
getId("side_nave").style.display="none";
}else{
getId("side_nave").style.display="block";
}
};
getId("side_nave").getElementsByTagName("span")[0].onclick=function(){
getId("side_nave").style.display="none";
};