简易博客[ html + css ] 练习

1. 前言

  通过使用 html + css 编写一个简易的博客作为入门练习

2. 代码及实现

2.1 目录结构

 

2.2 代码部分

复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <link href="https://cdn.bootcss.com/normalize/8.0.1/normalize.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/main.css">
    <title>Blogs</title>
</head>
<body>
    <div class="side-bar">
        <div class="header">
            <a href="" class="logo">周杰伦</a>
            <div class="intro">哼哼哈嘿</div>
        </div>
        <div class="nav">
            <a href="#" class="item">关于我</a>
            <a href="#" class="item">关于你</a>
            <a href="#" class="item">关于他</a>
        </div>
        <div class="tag-list">
            <a href="#" class="item">HTML</a>
            <a href="#" class="item">CSS</a>
            <a href="#" class="item">JS</a>
        </div>
    </div>
    <div class="main">
        <div class="article-list">
            <div class="item">
                <a href="article.html" class="title">彩虹</a>
                <div class="status">发布于:2019-10-10 | 阅读:3500 | #HTML #CSS</div>
                <div class="content">看不见你的笑,我怎么睡的着.</div>
            </div>
            <div class="item">
                <a href="#" class="title">彩虹</a>
                <div class="status">发布于:2019-10-10 | 阅读:3500 | #HTML #CSS</div>
                <div class="content">看不见你的笑,我怎么睡的着.</div>
            </div>
            <div class="item">
                <a href="#" class="title">彩虹</a>
                <div class="status">发布于:2019-10-10 | 阅读:3500 | #HTML #CSS</div>
                <div class="content">看不见你的笑,我怎么睡的着.</div>
            </div>
        </div>
    </div>
</body>
</html>
index.html
复制代码
复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <link href="https://cdn.bootcss.com/normalize/8.0.1/normalize.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/main.css">
    <title>Blogs</title>
</head>
<body>
    <div class="side-bar">
        <div class="header">
            <a href="" class="logo">周杰伦</a>
            <div class="intro">哼哼哈嘿</div>
        </div>
        <div class="nav">
            <a href="#" class="item">关于我</a>
            <a href="#" class="item">关于你</a>
            <a href="#" class="item">关于他</a>
        </div>
        <div class="tag-list">
            <a href="#" class="item">HTML</a>
            <a href="#" class="item">CSS</a>
            <a href="#" class="item">JS</a>
        </div>
    </div>
    <div class="main">
            <div class="article">
                <h1 class="title">彩虹</h1>
                <div class="content">
                    <div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias, aliquam aspernatur commodi
                        corporis ducimus in inventore iusto laborum libero maxime nemo nobis nostrum omnis perspiciatis
                        quibusdam saepe, sequi tempora velit.
                    </div>
                    <div>Cupiditate dolore est maxime vero? Cum illum minima modi nobis qui reprehenderit sed?
                        Consequatur distinctio eius nam quae vitae! Alias, beatae dolorum enim hic id impedit nobis
                        suscipit temporibus veniam.
                    </div>
                    <div>Ab, architecto aspernatur autem enim fuga maxime odio reiciendis reprehenderit suscipit velit?
                        Itaque labore porro recusandae vel velit. Ad at, dignissimos error illo iusto laboriosam maxime
                        non odit quod voluptatem.
                    </div></div>
            </div>
    </div>
</body>
</html>
article.html
复制代码
复制代码
body {
    background-color: #454545;
    line-height: 1.7;
}

body, a {
    color: white;
}

a {
    text-decoration: none;
}

.side-bar {
    float: left;
    width: 20%;
    position: fixed;
}

.main {
    float: right;
    width: 80%;
    color: #454545;
}

.side-bar > * {
    padding: 10px 15px;
}

.side-bar .header .logo {
    line-height: 1;
    display: inline-block;
    font-size: 30px;
    border: 3px solid white;
    padding: 10px 20px;
    margin-bottom: 10px;
}

.side-bar .nav a,
.side-bar .tag-list a {
    display: block;
    padding: 5px;
    transition: color 200ms;
    color: #666666;
}

.side-bar .nav a:hover,
.side-bar .tag-list a:hover {
    color: #eeeeee;
}

.side-bar .nav a {
    font-weight: 700;
}

.side-bar .tag-list a:before {
    content: '#';
}

.main .article-list,
.main .article {
    margin-right: 30%;
    background-color: white;
    padding: 20px 30px;
}

.article-list .item {
    margin-bottom: 25px;
}

.article-list .item .title {
    color: #454545;
    font-size: 22px;
    font-weight: 700;
}

.article-list .item .status {
    color: #cccccc;
    font-size: 13px;
}

.article-list .item > * {
    margin-bottom: 10px;
}
main.css
复制代码

 

 

2.3 展示图

 

index.html

 

 

 article.html

 

3. 总结

通过 简易博客 的练习,总结知识点如下:

 

1. 在编写 页面的时候,首先应该讲 HTML 布局写出来,也就是应该先架构 HTML 代码部分,HTML 代码部分完成,再进行 CSS 部分的编写。

2. 写 HTML 代码的时候,应该从整体上规划布局,比如 index.html   我第一次看到的时候以为是 三个 div 的 【左 中 右】,其实应该是两个 div 一个背景图而已。

3. CSS 代码中,要总结的知识点比较多,重点总结如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
a {
    text-decoration: none;
}
 
text-decoration: none; 取消 a 标签的下划线
 
 
display: inline-block;
 
注意 display 的使用,参考:
http://www.w3school.com.cn/cssref/pr_class_display.asp
 
 
transition: color 200ms;
 
延迟 2 毫秒,这样看起来更加丝滑
 
.side-bar .nav a:hover
 
hover 鼠标指针选中时的样式
 
 
 
.side-bar {
    float: left;   
    width: 20%;
    position: fixed;
}
 
float: left;   
width: 20%;   
 
float 一般为 left right ,而且配合 width 使用 left right 加起来 100%
position: fixed 生成绝对定位的元素
 
position 参考:
http://www.w3school.com.cn/cssref/pr_class_position.asp
 
 
border: 3px solid white;    画边框必要属性,solid 为实线
 
 
 
其他还要注意:
padding
margin
应该使用在什么地方比较合适。

本文作者:hukey

本文链接:https://www.cnblogs.com/hukey/p/10772845.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   hukey  阅读(1633)  评论(0编辑  收藏  举报
历史上的今天:
2018-04-26 [ python ] 项目二:主机批量管理程序
2018-04-26 [ python ] hasattr()、getattr()、setattr() 三者关系及运用
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
  1. 1 彩虹 Jay
彩虹 - Jay
00:00 / 00:00
An audio error has occurred.

彩虹 + 轨迹 (Live) - 周杰伦 (Jay Chou)

彩虹

词:周杰伦

曲:周杰伦

哪里有彩虹告诉我

哪里有彩虹告诉我

能不能把我的愿望还给我

能不能把我的愿望还给我

为什么天这么安静

为什么天这么安静

所有的云都跑到我这里

有没有口罩一个给我

有没有口罩一个给我

释怀说了太多就成真不了

释怀说了太多就成真不了

也许时间是一种解药

也许时间是一种解药

也是我现在正服下的毒药

也是我现在正服下的毒药

看不见你的笑 我怎么睡得着

看不见你的笑 我怎么睡得着

你的声音这么近我却抱不到

你的声音这么近我却抱不到

没有地球太阳还是会绕

没有地球太阳还是会绕

没有理由我也能自己走

没有理由我也能自己走

你要离开 我知道很简单

你要离开 我知道很简单

你说依赖 是我们的阻碍

你说依赖 是我们的阻碍

就算放开 但能不能别没收我的爱

就算放开 但能不能别没收我的爱

当作我最后才明白

当作我最后才明白

看不见你的笑 要我怎么睡得着

看不见你的笑 要我怎么睡得着

你的声音这么近我却抱不到

没有地球太阳还是会绕 会绕

没有理由我也能自己走掉

释怀说了太多就成真不了

也许时间是一种解药 解药

也是我现在正服下的毒药

轨迹

词:黄俊郎

曲:周杰伦

我会发着呆然后忘记你

接着紧紧闭上眼

想着哪一天 会有人代替

想着哪一天 会有人代替

让我不再想念你

我会发着呆 然后微微笑

我会发着呆 然后微微笑

接着紧紧闭上眼

又想了一遍 你温柔的脸

又想了一遍 你温柔的脸

在我忘记之前