效果图:
HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Blog页面示例</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<!--左边栏开始-->
<div class="div-left">
<div class="header-img">
<img src="1.png" alt="">
</div>
<div class="blog-name">小强的狗窝</div>
<div class="blog-info">这只狗很懒,什么都没有留下</div>
<!--链接区开始-->
<div class="blog-links">
<ul>
<li><a href="">关于我</a></li>
<li><a href="">关于他</a></li>
<li><a href="">关于你</a></li>
</ul>
</div>
<!--文章分类开始-->
<div class="blog-tags">
<ul>
<li><a href="">JS</a></li>
<li><a href="">CSS</a></li>
<li><a href="">HTML</a></li>
</ul>
</div>
</div>
<!--左边栏结束-->
<!--右边栏开始-->
<div class="div-right">
<div class="article-list">
<div class="article">
<div class="article-title">
<h1 class="article-name">海燕</h1>
<span class="article-date">2019-03-16</span>
</div>
<div class="article-info">
在苍茫的大海上,狂风卷积着乌云,在乌云和大海之间,海燕像黑色的闪电,在高傲的飞翔着.
</div>
<div class="article-tag">#HTML #CSS</div>
</div>
<div class="article">
<div class="article-title">
<h1 class="article-name">海燕</h1>
<span class="article-date">2019-03-16</span>
</div>
<div class="article-info">
在苍茫的大海上,狂风卷积着乌云,在乌云和大海之间,海燕像黑色的闪电,在高傲的飞翔着.
</div>
<div class="article-tag">#HTML #CSS</div>
</div>
<div class="article">
<div class="article-title">
<h1 class="article-name">海燕</h1>
<span class="article-date">2019-03-16</span>
</div>
<div class="article-info">
在苍茫的大海上,狂风卷积着乌云,在乌云和大海之间,海燕像黑色的闪电,在高傲的飞翔着.
</div>
<div class="article-tag">#HTML #CSS</div>
</div>
<div class="article">
<div class="article-title">
<h1 class="article-name">海燕</h1>
<span class="article-date">2019-03-16</span>
</div>
<div class="article-info">
在苍茫的大海上,狂风卷积着乌云,在乌云和大海之间,海燕像黑色的闪电,在高傲的飞翔着.
</div>
<div class="article-tag">#HTML #CSS</div>
</div>
</div>
</div>
<!--右边栏结束-->
</body>
</html>
CSS文件代码:
/*Blog页面相关样式*/
/*公用样式*/
* {
font-family: "Microsoft Yahei", "微软雅黑", "Arial", sans-serif;
font-size: 14px;
margin: 0;
padding: 0;
}
/*去掉a标签的下划线*/
a {
text-decoration: none;
}
/*左边栏样式*/
.div-left {
width: 20%;
background-color: rgb(76,77,76);
height: 100%;
position: fixed;
left: 0;
top: 0;
}
.header-img {
height: 128px;
width: 128px;
border: 5px solid white;
border-radius: 50%;
overflow: hidden;
margin: 0 auto;
margin-top: 20px;
}
.header-img>img {
max-width: 100%;
}
.blog-name {
color: white;
font-size: 24px;
font-weight: bold;
text-align: center;
margin-top: 15px;
}
/*bolg介绍*/
.blog-info {
color: white;
text-align: center;
border: 2px solid white;
margin: 5px 15px;
}
/*链接组和标签组*/
.blog-links,
.blog-tags {
text-align: center;
margin-top: 20px;
}
.blog-links a,
.blog-tags a {
color: #eee;
}
.blog-tags a:before {
content: "#";
}
/*右边栏样式*/
.div-right {
width: 80%;
background-color: rgb(238,237,237);
height: 1000px;
float: right;
}
.article-list {
margin-right: 10%;
margin-left: 30px;
margin-top: 30px;
}
.article {
background: white;
margin-bottom: 15px;
}
.article-name {
display: inline-block;
}
.article-title {
padding: 15px;
border-left: 3px solid red;
}
.article-info {
padding: 15px;
}
.article-tag {
padding: 15px 0;
margin: 15px;
border-top: 1px solid #eeeeee;
}
/*文章发布时间*/
.article-date {
float: right;
}