博客系统——前端部分

news2024/9/24 3:20:16

目录

一、博客页面介绍

二、实现博客列表页

1、先实现导航栏

2、页面主体

左侧区域的实现:​编辑

右侧页面的实现:​编辑

博客列表页代码汇总:

三、实现博客详情页

 代码实现:

四、实现博客登录页​编辑

五、博客编辑页

六、全部代码展示

blog_detail.html

blog_edit.html

blog_list.html

login.html

blog_detail.css

blog_edit.css

blog_list.css

common.css

login.css


一、博客页面介绍

要实现一个博客系统,我们得先构造出它的页面:

一共有四个页面:

1、博客列表页

 2、博客详情页:

显示这一个博客里面的具体内容

 3、登录页

 4、博客编辑页

 发布新博客,在这个博客页面进行编辑

 关于里面的 markdown 编辑器,我们直接使用开源的项目集成进来即可,不需要我们从头实现


二、实现博客列表页

1、先实现导航栏

导航栏各个页面都有

我们把导航栏的样式给单独放到一个common.css 中,让各个页面来引用

通过对导航栏进行调整,我们目前的导航栏是这个样子的:

但是我们还缺少一个半透明的效果, 我们可以在设置导航栏颜色的地方加一个数值 a

表示的就是透明度:

加上透明度后,我们的导航栏是这个样子的:

    <!-- 这是一个导航栏 -->
    <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
        <a href="#">注销</a>
    </div>

 common.css 部分代码:

/* 写样式的起手:先取出浏览器的公共样式,并且设置 border-box,避免元素盒子被内边距和边框撑大 */
*{
    margin:0;
    padding:0;
    box-sizing: border-box;
}

html,body{
    /* 
    html 是我们页面的最顶层元素,高度 100% 是相对父元素来说是 100%(和父元素一样高)
    对于 html 标签来说,父元素就是浏览器窗口,浏览器窗口多高,html 就多高
    body 的父亲是 html ,设为 100%,意思是 body 和 html 一样高
    此时,body 和 html 高度和浏览器窗口一样高
    如果不设置高度,此时元素的默认高度取决于内部的内容
     */
    height: 100%;

}

body{
    /* 相对路径的基准路径,就是当前文件所在路径 */
    background-image: url(../image/背景图.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
}

/* 实现导航栏的样式 */

.nav{
     /* 宽度和父元素一样宽 */
     /* 块级元素来说,样式默认就是100% */
    width:100%;
    height: 50px;
    background-color: rgba(50, 50, 50,0.4);
    color: white;

    /* 导航栏里面的元素都是水平排列,弹性布局来设置 */
    display: flex;
    /* 垂直方向子元素居中 */
    align-items: center;

}

.nav img{
    width:40px;
    height: 40px;
    margin-left:30px;
    margin-right: 10px;
    /* 让元素变圆,把内切圆半径设置为宽度的一半,此时就正好是一个圆形 */
    border-radius: 50%;
}

.nav .spacer{
    width:70%
}

.nav a{
    color: white;
    /* 去掉下划线 */
    text-decoration: none;
    /* 为了让这几个 a 标签不要贴的这么紧凑,加上个内边距 
    使用 外边距也行,但是内边距更好,内边距也是元素的内容,可以增大用户点击的面积*/
    padding:0 10px;

}

2、页面主体

设置高度的时候,我们要注意主体页面的高度应该是整个页面的高度减去导航栏的高度

这里的 calc 相当于是 CSS 提供的一个函数

calc可以帮助我们计算页面的尺寸,针对 绝对值 和 百分数 尺寸进行混合运算

注意:这里的 - 两侧必须要有一个空格, - 有可能是标识符的一部分,如果 CSS 要想表示减法运算,就得加上空格


左侧区域的实现:

我们给图片设置成 140px * 140px,左右各自留 30px 的间距

同时让图片和上方也有 30px 的间距


右侧页面的实现:

 先搞定一片,其他的就好办了

 注意:在 html 中,存在一些转义字符: < &lt  > &gt

 现在有一个问题,那就是当我们多展示几篇博客之后,便会出现这种情况:

针对这个滚动的问题, 我们就可以把滚动条加到 containner-right 上

这样滚动的时候,就不会整个页面一起滚动了,而是只滚动一部分

博客列表页代码汇总:

common.css:

/* 写样式的起手:先取出浏览器的公共样式,并且设置 border-box,避免元素盒子被内边距和边框撑大 */
*{
    margin:0;
    padding:0;
    box-sizing: border-box;
}

html,body{
    /* 
    html 是我们页面的最顶层元素,高度 100% 是相对父元素来说是 100%(和父元素一样高)
    对于 html 标签来说,父元素就是浏览器窗口,浏览器窗口多高,html 就多高
    body 的父亲是 html ,设为 100%,意思是 body 和 html 一样高
    此时,body 和 html 高度和浏览器窗口一样高
    如果不设置高度,此时元素的默认高度取决于内部的内容
     */
    height: 100%;

}

body{
    /* 相对路径的基准路径,就是当前文件所在路径 */
    background-image: url(../image/背景图.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
}

/* 实现导航栏的样式 */

.nav{
     /* 宽度和父元素一样宽 */
     /* 块级元素来说,样式默认就是100% */
    width:100%;
    height: 50px;
    background-color: rgba(50, 50, 50,0.4);
    color: white;

    /* 导航栏里面的元素都是水平排列,弹性布局来设置 */
    display: flex;
    /* 垂直方向子元素居中 */
    align-items: center;

}

.nav img{
    width:40px;
    height: 40px;
    margin-left:30px;
    margin-right: 10px;
    /* 让元素变圆,把内切圆半径设置为宽度的一半,此时就正好是一个圆形 */
    border-radius: 50%;
}

.nav .spacer{
    width:70%
}

.nav a{
    color: white;
    /* 去掉下划线 */
    text-decoration: none;
    /* 为了让这几个 a 标签不要贴的这么紧凑,加上个内边距 
    使用 外边距也行,但是内边距更好,内边距也是元素的内容,可以增大用户点击的面积*/
    padding:0 10px;

}

/* 编写页面主体样式 */
.containner{
    /* 设置主体部分宽度 1000px */
    width: 1000px;
    /* 高度能够填充整个页面*/
    height: calc(100% - 50px);
    /* 水平居中 */
    margin:0 auto;


    /* 弹性布局 */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.containner-left{
    /* 尺寸写百分数是相对于父元素为基准的 ,这里的父元素是 containner */
    height:100%;
    width:200px;


}

.containner-right{
    height:100%;
    /* 此处不设置为800,而是留了 5px,作为中缝 */
    width:795px;

    background-color: rgba(255, 255, 255,0.8);
    border-radius: 10px;

    /* 让这个元素自己能带上滚动条 */
    /* 这个属性表示如果内容没有溢出,就没有滚动条,如果溢出,就有滚动条 */
    overflow: auto;
}

/* 左侧用户信息 */
.card{
    background-color: rgba(255, 255, 255,0.8);
    border-radius: 10px;
    /* 设置内间距,让内容和边框之间有点距离 */
    padding:30px;
}

/* 用户头像 */
.card img{
    width:140px;
    height:140px;
    border-radius: 50%;
}

/* 用户名字 */
.card h3{
    /* 让文字水平居中 */
    text-align: center;
    /* 让文字和上下都有边距 */
    /* 此处使用内边距和外边距都可,但是会更倾向于 内边距 */
    padding:10px;
}

/* 用户的 blog 链接 */
.card a{
    /* a 标签是行内标签 */
    text-align: center;
    /* 为了配合上述样式,设置成块级元素 */
    display: block;
    color: #666;
    text-decoration: none;
    padding:10px;
}

.card .counter{
    /* 为了让里面的元素水平排列,使用弹性布局 */
    display: flex;
    justify-content: space-around;
    padding:5px;
}

blog_list.css

/* 这个文件是给博客列表页实现的样式 */

/* 设置整个博客的容易样式 */
.blog{
    width:100%;
    padding: 20px;
}

.blog .title{
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    padding: 10px;
}

.blog .date{
    text-align: center;
    color: rgb(15,189,114);
    padding:10px;
}

.blog .desc{
    text-indent: 2em;
}

.blog a{
    /* a 标签不方便设置样式,所以设置成块级元素 */
    display: block;
    width:120px;
    height:40px;
    /* 设置水平居中 */
    margin-top: 20px auto;
    margin-left: auto;
    margin-right: auto;
    /* 设置一个边框 */
    border: 2px solid black;
    /* 让文字水平居中 */
    text-align: center;
    /* 让文字垂直居中 */
    line-height: 35px;
    /* 去掉下划线*/
    text-decoration: none;
    /* 文字改成黑色 */
    color: black;
    /* 圆角矩形 */
    border-radius: 10px;
    /* 给鼠标悬停加一个过度效果 */
    transition:all 0.8s;
}

/* 设置一下,让鼠标滑倒按钮上有一个变化 */
.blog a:hover{
    color:white;
    background-color: #666;
}

blog_list.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客列表页</title>
    <link rel="stylesheet" href="CSS/common.css">
    <link rel="stylesheet" href="CSS/blog_list.css">
</head>
<body>
    <!-- 这是一个导航栏 -->
    <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
        <a href="#">注销</a>
    </div>
    <!-- 页面主体部分 -->
    <div class="containner">
        <!-- 左侧信息 -->
        <div class="containner-left">
            <!-- 使用这个 .card 表示用户信息 -->
            <div class="card">
                <!-- 用户头像 -->
                <img src="image/logo.jpg" alt="">
                <!-- 用户名字 -->
                <h3>馒头警告</h3>
                <a href="#">blog 地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>


        <!-- 右侧信息 -->
    <div class="containner-right">
        <!-- 表示一篇博客 -->
        <div class="blog">
            <!-- 博客的标题 -->
            <div class="title">第一篇博客</div>
            <!-- 发布时间 -->
            <div class="date">2023-08-20</div>
            <!-- 博客的摘要 -->
            <div class="desc">好好学习,天天向上 Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam blanditiis iure cum rerum. Libero iusto commodi tempora dolore asperiores, nobis earum officia neque, reprehenderit consectetur minima dolor minus corrupti voluptate.</div>
            <!-- 查看全文按钮 -->
            <a href="#">查看全文 &gt;&gt; </a>
        </div>
                <!-- 表示一篇博客 -->
                <div class="blog">
                    <!-- 博客的标题 -->
                    <div class="title">第一篇博客</div>
                    <!-- 发布时间 -->
                    <div class="date">2023-08-20</div>
                    <!-- 博客的摘要 -->
                    <div class="desc">好好学习,天天向上 Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam blanditiis iure cum rerum. Libero iusto commodi tempora dolore asperiores, nobis earum officia neque, reprehenderit consectetur minima dolor minus corrupti voluptate.</div>
                    <!-- 查看全文按钮 -->
                    <a href="#">查看全文 &gt;&gt; </a>
                </div>
                <!-- 表示一篇博客 -->
                 <div class="blog">
                     <!-- 博客的标题 -->
                    <div class="title">第一篇博客</div>
                    <!-- 发布时间 -->
                     <div class="date">2023-08-20</div>
                      <!-- 博客的摘要 -->
                     <div class="desc">好好学习,天天向上 Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam blanditiis iure cum rerum. Libero iusto commodi tempora dolore asperiores, nobis earum officia neque, reprehenderit consectetur minima dolor minus corrupti voluptate.</div>
                     <!-- 查看全文按钮 -->
                     <a href="#">查看全文 &gt;&gt; </a>
                 </div>
     </div>

三、实现博客详情页

导航栏和左侧部分代码,我们可以直接将之前博客列表页相关部分的复制过来

此时,只需要对右侧主体部分进行编写即可

 代码实现:

blog_detail.css

/* 这个样式给多个详情页使用 */

.containner-right .title{
    text-align: center;
    padding: 30px;

}

.containner-right .date{
    color: rgb(15,189,114);
    text-align:  center;
    padding:10px;

}

.containner-right .content p{
    text-indent: 2em;
    padding :10px;
}

blog_detail.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客详情页</title>
    <link rel="stylesheet" href="CSS/common.css">
    <link rel="stylesheet" href="CSS/blog_detail.css">
</head>
<body>
     <!-- 这是一个导航栏 -->
     <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
        <a href="#">注销</a>
    </div>
    <div class="containner">
        <!-- 左侧信息 -->
        <div class="containner-left">
            <!-- 使用这个 .card 表示用户信息 -->
            <div class="card">
                <!-- 用户头像 -->
                <img src="image/logo.jpg" alt="">
                <!-- 用户名字 -->
                <h3>馒头警告</h3>
                <a href="#">blog 地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>
        <!-- 右侧信息 -->
        <div class="containner-right">
            <!-- 博客标题 -->
            <h3 class="title">我的第一篇博客</h3>
            <!-- 博客发布时间 -->
            <div class="date">2023-08-20</div>
            <!-- 博客正文 -->
            <div class="content">
                <p>
                    好好学习,天天向上 Lorem ipsum, dolor sit amet consectetur adipisicing elit. Architecto ab ullam suscipit aut illum nostrum accusamus laboriosam id, temporibus amet enim! Alias libero porro officia veritatis aliquam voluptas eveniet quod?
                </p>
                <p>
                    第二段内容 Lorem, ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis nam obcaecati est quia et, minima impedit culpa nulla asperiores velit praesentium voluptatum similique commodi eum, numquam, saepe modi aliquam porro.
                </p>
                <p>
                    第三段内容 Lorem, ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis nam obcaecati est quia et, minima impedit culpa nulla asperiores velit praesentium voluptatum similique commodi eum, numquam, saepe modi aliquam porro.
                </p>
            </div>
        </div>
    </div>
</body>
</html>

四、实现博客登录页

注意:登录页面是没有登录按钮的

注销指的是登录状态,在登录页面还没有进行登录,所以不应该提供注销按钮

在 CSS 中,实现垂直水平居中,有很多的写法

我们可以使用前面学过的弹性布局

代码:

login.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" href="CSS/common.css">
    <link rel="stylesheet" href="CSS/login.css">
</head>
<body>
     <!-- 这是一个导航栏 -->
     <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
    </div>
    <!-- 正文部分 -->
    <!-- 贯穿整个页面的容器 -->
    <div class="login-container">
        <!-- 垂直水平居中的对话框 -->
        <div class="login-dialog">
            <h3>登录</h3>
            <div class="row">
                <span>用户名</span>
                <input type="text" id = "username" placeholder="手机号 / 邮箱">
            </div>
            <div class="row">
                <span>密码</span>
                <input type="password" id = "password">
            </div>
            <div class="row">
                <button id = "submit">登录</button>
            </div>
        </div>
    </div>

</body>
</html>

login.css

/* 这个文件专门放登录页面的样式 */
.login-container{
    width:100%;
    height:calc(100% - 50px);
    /* 为了让对话框能垂直水平居中,使用弹性布局 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-dialog{
    width:400px;
    height:330px;
    background-color: rgba(255,255,255,0.8);
    border-radius: 10px;
}

.login-dialog h3{
    text-align: center;
    padding:50px 0;
}

.login-dialog .row{
    display: flex;
    height: 50px;
    justify-content: center;
    align-items: center;
}

.login-dialog .row span{
    width: 100px;
}

#username,#password{
    width:200px;
    height: 40px;
    border-radius: 10px;
    /* 去掉边框 */
    border: none;
    /* 放大字体 */
    font-size: 18px;
    padding-left:5px;
}

#submit{
    width:300px;
    height: 40px;
    color: white;
    background-color: orange;
    border: none;
    border-radius: 10px;
}

#submit:active{
    background-color: #666;
}

五、博客编辑页

editor.md

我们要做的工作:

1、把项目下载下来

2、把项目引入到我们的代码中

3、编写少量代码进行初始化

editor.md 还依赖了另外一个 js 库 : jquery

如何引入 jquery?

1、网上找到 jquery 源码

打开浏览器,在搜索框中输入 jquery cdn

然后找到这个链接,点开

 我们在其中选择这个版本的 jquery:

然后直接复制链接,在新的浏览器页打开

打开链接后,我们所看到的这些东西就是源码:

在这里,我们有两种做法:

1、直接全选这个页面里面的代码,新建一个 js 文件,粘贴进去就行了

2、 直接把 cdn 的地址,直接写到 src 的属性中,就不需要手动粘贴了

2、引入 editor.md

这个东西需要在 github 中查找

如果 github 打不开,可以尝试使用 steam ++ 作为加速器

在 guthub 中搜索 editor.md

 然后把源码下载下来

然后将文件拷贝到博客页面目录中,并且把这个目录名改成 editor.md

当前,我们已经把库下载下来了,就需要把这个库引入到项目代码中,也就是让 html 引入库里的文件(引入 css 和 js 文件)

如何引入 editor.md?

1、先保证页面中有一个 id 为 editor 的 div

2、引入 editor.md 对应的 css 和 js ,这些引入代码,必须放到 jquery 引入代码的下面

<!-- 引入 editor.md 的依赖 -->
    <link rel="stylesheet" href="editor.md/css/editormd.min.css" />
    <script src="js/jquery.min.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>

注意:此处代码中的路径必须要和磁盘中的路径一致

3、编写初始化代码(官方文档上有,直接复制粘贴即可)

 // 初始化编辑器
        let editor = editormd("editor", {
            // 这里的尺寸必须在这里设置. 设置样式会被 editormd 自动覆盖掉. 
            width: "100%",
            // 设定编辑器高度
            height: "calc(100% - 50px)",
            // 编辑器中的初始内容
            markdown: "# 在这里写下一篇博客",
            // 指定 editor.md 依赖的插件路径
            path: "editor.md/lib/"
        });

此时,markdown 编译器就引入完毕了

当我们给 #editor 设置背景半透明,但是没有生效

这是因为, #editor 自身半透明,但是这里面的元素不是透明的,导致仍然看不到背景

我们可以通过 opacity 设置半透明

这个会使所有的子元素都变成半透明

六、全部代码展示

blog_detail.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客详情页</title>
    <link rel="stylesheet" href="CSS/common.css">
    <link rel="stylesheet" href="CSS/blog_detail.css">
</head>
<body>
     <!-- 这是一个导航栏 -->
     <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
        <a href="#">注销</a>
    </div>
    <div class="containner">
        <!-- 左侧信息 -->
        <div class="containner-left">
            <!-- 使用这个 .card 表示用户信息 -->
            <div class="card">
                <!-- 用户头像 -->
                <img src="image/logo.jpg" alt="">
                <!-- 用户名字 -->
                <h3>馒头警告</h3>
                <a href="#">blog 地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>
        <!-- 右侧信息 -->
        <div class="containner-right">
            <!-- 博客标题 -->
            <h3 class="title">我的第一篇博客</h3>
            <!-- 博客发布时间 -->
            <div class="date">2023-08-20</div>
            <!-- 博客正文 -->
            <div class="content">
                <p>
                    好好学习,天天向上 Lorem ipsum, dolor sit amet consectetur adipisicing elit. Architecto ab ullam suscipit aut illum nostrum accusamus laboriosam id, temporibus amet enim! Alias libero porro officia veritatis aliquam voluptas eveniet quod?
                </p>
                <p>
                    第二段内容 Lorem, ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis nam obcaecati est quia et, minima impedit culpa nulla asperiores velit praesentium voluptatum similique commodi eum, numquam, saepe modi aliquam porro.
                </p>
                <p>
                    第三段内容 Lorem, ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis nam obcaecati est quia et, minima impedit culpa nulla asperiores velit praesentium voluptatum similique commodi eum, numquam, saepe modi aliquam porro.
                </p>
            </div>
        </div>
    </div>
</body>
</html>

blog_edit.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客详情页</title>
    <link rel="stylesheet" href="CSS/common.css">
    <link rel="stylesheet" href="CSS/blog_detail.css">
</head>
<body>
     <!-- 这是一个导航栏 -->
     <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
        <a href="#">注销</a>
    </div>
    <div class="containner">
        <!-- 左侧信息 -->
        <div class="containner-left">
            <!-- 使用这个 .card 表示用户信息 -->
            <div class="card">
                <!-- 用户头像 -->
                <img src="image/logo.jpg" alt="">
                <!-- 用户名字 -->
                <h3>馒头警告</h3>
                <a href="#">blog 地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>
        <!-- 右侧信息 -->
        <div class="containner-right">
            <!-- 博客标题 -->
            <h3 class="title">我的第一篇博客</h3>
            <!-- 博客发布时间 -->
            <div class="date">2023-08-20</div>
            <!-- 博客正文 -->
            <div class="content">
                <p>
                    好好学习,天天向上 Lorem ipsum, dolor sit amet consectetur adipisicing elit. Architecto ab ullam suscipit aut illum nostrum accusamus laboriosam id, temporibus amet enim! Alias libero porro officia veritatis aliquam voluptas eveniet quod?
                </p>
                <p>
                    第二段内容 Lorem, ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis nam obcaecati est quia et, minima impedit culpa nulla asperiores velit praesentium voluptatum similique commodi eum, numquam, saepe modi aliquam porro.
                </p>
                <p>
                    第三段内容 Lorem, ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis nam obcaecati est quia et, minima impedit culpa nulla asperiores velit praesentium voluptatum similique commodi eum, numquam, saepe modi aliquam porro.
                </p>
            </div>
        </div>
    </div>
</body>
</html>

blog_list.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客列表页</title>
    <link rel="stylesheet" href="CSS/common.css">
    <link rel="stylesheet" href="CSS/blog_list.css">
</head>
<body>
    <!-- 这是一个导航栏 -->
    <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
        <a href="#">注销</a>
    </div>
    <!-- 页面主体部分 -->
    <div class="containner">
        <!-- 左侧信息 -->
        <div class="containner-left">
            <!-- 使用这个 .card 表示用户信息 -->
            <div class="card">
                <!-- 用户头像 -->
                <img src="image/logo.jpg" alt="">
                <!-- 用户名字 -->
                <h3>馒头警告</h3>
                <a href="#">blog 地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>


        <!-- 右侧信息 -->
    <div class="containner-right">
        <!-- 表示一篇博客 -->
        <div class="blog">
            <!-- 博客的标题 -->
            <div class="title">第一篇博客</div>
            <!-- 发布时间 -->
            <div class="date">2023-08-20</div>
            <!-- 博客的摘要 -->
            <div class="desc">好好学习,天天向上 Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam blanditiis iure cum rerum. Libero iusto commodi tempora dolore asperiores, nobis earum officia neque, reprehenderit consectetur minima dolor minus corrupti voluptate.</div>
            <!-- 查看全文按钮 -->
            <a href="#">查看全文 &gt;&gt; </a>
        </div>
                <!-- 表示一篇博客 -->
                <div class="blog">
                    <!-- 博客的标题 -->
                    <div class="title">第一篇博客</div>
                    <!-- 发布时间 -->
                    <div class="date">2023-08-20</div>
                    <!-- 博客的摘要 -->
                    <div class="desc">好好学习,天天向上 Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam blanditiis iure cum rerum. Libero iusto commodi tempora dolore asperiores, nobis earum officia neque, reprehenderit consectetur minima dolor minus corrupti voluptate.</div>
                    <!-- 查看全文按钮 -->
                    <a href="#">查看全文 &gt;&gt; </a>
                </div>
                <!-- 表示一篇博客 -->
                 <div class="blog">
                     <!-- 博客的标题 -->
                    <div class="title">第一篇博客</div>
                    <!-- 发布时间 -->
                     <div class="date">2023-08-20</div>
                      <!-- 博客的摘要 -->
                     <div class="desc">好好学习,天天向上 Lorem ipsum dolor sit amet consectetur adipisicing elit. Aperiam blanditiis iure cum rerum. Libero iusto commodi tempora dolore asperiores, nobis earum officia neque, reprehenderit consectetur minima dolor minus corrupti voluptate.</div>
                     <!-- 查看全文按钮 -->
                     <a href="#">查看全文 &gt;&gt; </a>
                 </div>
     </div>
</body>
</html>

login.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" href="CSS/common.css">
    <link rel="stylesheet" href="CSS/login.css">
</head>
<body>
     <!-- 这是一个导航栏 -->
     <div class="nav">
        <img src="image/logo2.png" alt="">
        <span class = "title">我的博客系统</span>
        <!-- 这个标签仅仅用于占位,把这几个 a 标签挤到右侧去 -->
        <div class="spacer"></div>
        <a href="#">主页</a>
        <a href="#">写博客</a>
    </div>
    <!-- 正文部分 -->
    <!-- 贯穿整个页面的容器 -->
    <div class="login-container">
        <!-- 垂直水平居中的对话框 -->
        <div class="login-dialog">
            <h3>登录</h3>
            <div class="row">
                <span>用户名</span>
                <input type="text" id = "username" placeholder="手机号 / 邮箱">
            </div>
            <div class="row">
                <span>密码</span>
                <input type="password" id = "password">
            </div>
            <div class="row">
                <button id = "submit">登录</button>
            </div>
        </div>
    </div>

</body>
</html>

blog_detail.css

/* 这个样式给多个详情页使用 */

.containner-right .title{
    text-align: center;
    padding: 30px;

}

.containner-right .date{
    color: rgb(15,189,114);
    text-align:  center;
    padding:10px;

}

.containner-right .content p{
    text-indent: 2em;
    padding :10px;
}

blog_edit.css

/* 这个文件用来写博客编辑页的样式 */

.blog-edit-container{
    width: 1000px;
    height: calc(100% - 50px);
    margin:0 auto;
}

.blog-edit-container .title{
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#title{
    height: 40px;
    width: 895px;
    border: none;
    padding-left: 5px;
    font-size: 20px;
    border-radius: 10px;
    /* 去掉轮廓线(鼠标选中后的黑圈) */
    outline: none;
    /* 设置背景半透明 */
    background-color: rgba(255,255,255,0.7);
}
/*  获取到焦点*/
#title:focus{
    background-color: white;
}
#submit{
    height: 40px;
    width: 100px;
    color:white;
    background-color: orange;
    border-radius: 10px;
    border: none;
}

#submit:active{
    background-color: #666;
}

#editor{
    border-radius: 10px;
    opacity: 80%;

}

blog_list.css

/* 这个文件是给博客列表页实现的样式 */

/* 设置整个博客的容易样式 */
.blog{
    width:100%;
    padding: 20px;
}

.blog .title{
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    padding: 10px;
}

.blog .date{
    text-align: center;
    color: rgb(15,189,114);
    padding:10px;
}

.blog .desc{
    text-indent: 2em;
}

.blog a{
    /* a 标签不方便设置样式,所以设置成块级元素 */
    display: block;
    width:120px;
    height:40px;
    /* 设置水平居中 */
    margin-top: 20px auto;
    margin-left: auto;
    margin-right: auto;
    /* 设置一个边框 */
    border: 2px solid black;
    /* 让文字水平居中 */
    text-align: center;
    /* 让文字垂直居中 */
    line-height: 35px;
    /* 去掉下划线*/
    text-decoration: none;
    /* 文字改成黑色 */
    color: black;
    /* 圆角矩形 */
    border-radius: 10px;
    /* 给鼠标悬停加一个过度效果 */
    transition:all 0.8s;
}

/* 设置一下,让鼠标滑倒按钮上有一个变化 */
.blog a:hover{
    color:white;
    background-color: #666;
}

common.css

/* 写样式的起手:先取出浏览器的公共样式,并且设置 border-box,避免元素盒子被内边距和边框撑大 */
*{
    margin:0;
    padding:0;
    box-sizing: border-box;
}

html,body{
    /* 
    html 是我们页面的最顶层元素,高度 100% 是相对父元素来说是 100%(和父元素一样高)
    对于 html 标签来说,父元素就是浏览器窗口,浏览器窗口多高,html 就多高
    body 的父亲是 html ,设为 100%,意思是 body 和 html 一样高
    此时,body 和 html 高度和浏览器窗口一样高
    如果不设置高度,此时元素的默认高度取决于内部的内容
     */
    height: 100%;

}

body{
    /* 相对路径的基准路径,就是当前文件所在路径 */
    background-image: url(../image/背景图.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
}

/* 实现导航栏的样式 */

.nav{
     /* 宽度和父元素一样宽 */
     /* 块级元素来说,样式默认就是100% */
    width:100%;
    height: 50px;
    background-color: rgba(50, 50, 50,0.4);
    color: white;

    /* 导航栏里面的元素都是水平排列,弹性布局来设置 */
    display: flex;
    /* 垂直方向子元素居中 */
    align-items: center;

}

.nav img{
    width:40px;
    height: 40px;
    margin-left:30px;
    margin-right: 10px;
    /* 让元素变圆,把内切圆半径设置为宽度的一半,此时就正好是一个圆形 */
    border-radius: 50%;
}

.nav .spacer{
    width:70%
}

.nav a{
    color: white;
    /* 去掉下划线 */
    text-decoration: none;
    /* 为了让这几个 a 标签不要贴的这么紧凑,加上个内边距 
    使用 外边距也行,但是内边距更好,内边距也是元素的内容,可以增大用户点击的面积*/
    padding:0 10px;

}

/* 编写页面主体样式 */
.containner{
    /* 设置主体部分宽度 1000px */
    width: 1000px;
    /* 高度能够填充整个页面*/
    height: calc(100% - 50px);
    /* 水平居中 */
    margin:0 auto;


    /* 弹性布局 */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.containner-left{
    /* 尺寸写百分数是相对于父元素为基准的 ,这里的父元素是 containner */
    height:100%;
    width:200px;


}

.containner-right{
    height:100%;
    /* 此处不设置为800,而是留了 5px,作为中缝 */
    width:795px;

    background-color: rgba(255, 255, 255,0.8);
    border-radius: 10px;

    /* 让这个元素自己能带上滚动条 */
    /* 这个属性表示如果内容没有溢出,就没有滚动条,如果溢出,就有滚动条 */
    overflow: auto;
}

/* 左侧用户信息 */
.card{
    background-color: rgba(255, 255, 255,0.8);
    border-radius: 10px;
    /* 设置内间距,让内容和边框之间有点距离 */
    padding:30px;
}

/* 用户头像 */
.card img{
    width:140px;
    height:140px;
    border-radius: 50%;
}

/* 用户名字 */
.card h3{
    /* 让文字水平居中 */
    text-align: center;
    /* 让文字和上下都有边距 */
    /* 此处使用内边距和外边距都可,但是会更倾向于 内边距 */
    padding:10px;
}

/* 用户的 blog 链接 */
.card a{
    /* a 标签是行内标签 */
    text-align: center;
    /* 为了配合上述样式,设置成块级元素 */
    display: block;
    color: #666;
    text-decoration: none;
    padding:10px;
}

.card .counter{
    /* 为了让里面的元素水平排列,使用弹性布局 */
    display: flex;
    justify-content: space-around;
    padding:5px;
}

login.css

/* 这个文件专门放登录页面的样式 */
.login-container{
    width:100%;
    height:calc(100% - 50px);
    /* 为了让对话框能垂直水平居中,使用弹性布局 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-dialog{
    width:400px;
    height:330px;
    background-color: rgba(255,255,255,0.8);
    border-radius: 10px;
}

.login-dialog h3{
    text-align: center;
    padding:50px 0;
}

.login-dialog .row{
    display: flex;
    height: 50px;
    justify-content: center;
    align-items: center;
}

.login-dialog .row span{
    width: 100px;
}

#username,#password{
    width:200px;
    height: 40px;
    border-radius: 10px;
    /* 去掉边框 */
    border: none;
    /* 放大字体 */
    font-size: 18px;
    padding-left:5px;
}

#submit{
    width:300px;
    height: 40px;
    color: white;
    background-color: orange;
    border: none;
    border-radius: 10px;
}

#submit:active{
    background-color: #666;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/935784.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【赋权算法】Python实现熵权法

在开始之前&#xff0c;我们先说一下信息熵的概念。 当一件事情发生&#xff0c;如果是意料之中&#xff0c;那么这个事情就并不能拿来当做茶余饭后的谈资&#xff0c;我们可以说这个事情并没有什么信息和价值。而当一件不可能发生的事情发生的时候&#xff0c;我们可能就会觉…

挖数据四周年庆典,壕礼不断,惊喜不停!

挖数据四周岁啦&#xff01;为了感谢广大用户们一路以来的支持与陪伴&#xff0c;我们特地准备了丰富的优惠活动&#xff0c;希望能够用最实际的行动来回馈您们的厚爱。四年的成长与蜕变&#xff0c;都是因为有您们的陪伴与鼓励&#xff0c;我们期待与您们一同分享这份喜悦与成…

Linux 基金会宣布正式进驻中国

在 LinuxCon 2017 &#xff08;北京&#xff09;即将召开前夕&#xff0c;我们Linux 中国会同 51CTO、开源中国对 Linux 基金会执行董事 Jim Zemlin 进行了一场远跨大洋的视频专访。 在这次专访中&#xff0c;Jim 先生回答了几个开源界和互联网领域关注的问题&#xff0c;并披…

PCI设备和PCI桥的配置空间(header_type0、header_type1)和配置命令(type0、type1)详解

1、PCI典型拓扑 2、type0和type1 名称含义Bus Number设备所在总线号Device Number设备分配到的设备号Function Number功能号&#xff0c;有的设备是支持多个功能的&#xff0c;最多8种功能Register Number要访问的寄存器地址 (1)type0和type1的区别&#xff1a;AD[1:0]是00代表…

几个nlp的小任务(生成式任务——语言模型(CLM与MLM))

@TOC 本章节需要用到的类库 微调任意Transformers模型(CLM因果语言模型、MLM遮蔽语言模型) CLM MLM 准备数据集 展示几个数据的结构

【AI底层逻辑】——篇章7(下):计算资源软件代码共享

续上篇... 目录 续上篇... 三、计算资源 1、第一阶段&#xff1a;数据大集中 2、第二阶段&#xff1a;资源云化 ①“云”的分类 ②虚拟化技术 ③边缘计算的普及 四、软件代码共享 总结 往期精彩&#xff1a; 三、计算资源 AlphaGo算法论文虽然已经发表&#xff0c;但…

华为OD七日集训第2期 - 按算法分类,由易到难,循序渐进,玩转OD(文末送书)

目录 一、适合人群二、本期训练时间三、如何参加四、7日集训第2期五、精心挑选21道高频100分经典题目&#xff0c;作为入门。第1天、逻辑分析第2天、字符串处理第3天、数据结构第4天、递归回溯第5天、二分查找第6天、深度优先搜索dfs算法第7天、动态规划 六、集训总结1、《代码…

rke安装k8s

1、修改集群中各物理机主机名hostname文件 # 查看 cat /etc/hostname # 命令修改 hostnamectl set-hostname k8s-master2、实现主机名与ip地址解析 # 查看cat /etc/hosts # 修改 vi /etc/hosts3、配置ip_forward过滤机制 # 修改 vi /etc/sysctl.conf net.ipv4.ip_forward1…

RT-Thread IO设备模型

IO设备模型 RTT提供了一套简单的I/O设备模型框架&#xff0c;它位于硬件和应用程序之间&#xff0c;共分成三层&#xff0c;从上到下分别是I/O设备管理层、设备驱动框架层、设备驱动层。 应用程序通过I/O设备管理接口获得正确的设备驱动&#xff0c;然后通过这个设备驱动与底层…

递归算法学习——全排列

目录 ​编辑 一&#xff0c;问题描述 1.例子&#xff1a; 题目接口&#xff1a; 二&#xff0c;问题分析和解决 1.问题分析 2.解题代码 一&#xff0c;问题描述 首先我们得来先看看全排列的问题描述。全排列问题的问题描述如下&#xff1a; 给定一个不含重复数字的数组 n…

DTC状态变化例子 4

例子1&#xff1a; 此示例概述了两个操作周期排放相关的 OBD DTC 中 DTC 状态位的操作。该图显示了两个操作周期排放相关的 OBD DTC 的处理。该处理也可应用于非排放相关的 OBD DTC&#xff0c;此处显示仅供一般参考。 0 接收到清除诊断信息 → DTC 状态字节初始化。 1, 2 相关…

基于类电磁机制算法优化的BP神经网络(预测应用) - 附代码

基于类电磁机制算法优化的BP神经网络&#xff08;预测应用&#xff09; - 附代码 文章目录 基于类电磁机制算法优化的BP神经网络&#xff08;预测应用&#xff09; - 附代码1.数据介绍2.类电磁机制优化BP神经网络2.1 BP神经网络参数设置2.2 类电磁机制算法应用 4.测试结果&…

RabbitMQ---订阅模型-Topic

订阅模型-Topic • Topic类型的Exchange与Direct相比&#xff0c;都是可以根据RoutingKey把消息路由到不同的队列。只不过Topic类型Exchange可以让队列在绑定Routing key 的时候使用通配符&#xff01; • Routingkey 一般都是有一个或多个单词组成&#xff0c;多个单词之间以…

【clojure】入门篇-01

一、环境的配置 1.java环境配置 clojureScript 需要java环境的配置需要下载jdk进行java环境变量配置 下载官网 java环境变量的配置教程 2.Leningen环境配置 1.下载.bat文件内容 2.配置环境变量 2.8.3及以上内容进行配置 lein教程 2.使用vscode vscode官网 下载插件 C…

SIP 协议路由规则详解

文章目录 SIP 路由关键字段SIP 路由图解 SIP 路由关键字段 SIP 协议实际上和 HTTP 类似&#xff0c;都是基于文本、可阅读的应用层协议&#xff0c;二者的不同之处在于 SIP 协议是有状态的。在 SIP 协议中&#xff0c;影响报文路由的相关字段如下表所示&#xff0c;总结起来如…

给微软.Net runtime运行时提交的几个Issues

前言 因为目前从事的CLRJIT,所以会遇到一些非常底层的问题&#xff0c;比如涉及到微软的公共运行时和即时编译器或者AOT编译器的编译异常等情况,这里分享下自己提的几个Issues。原文:微软.Net runtime运行时提交的几个Issues Issues 一.issues one 第一个System.Numerics.Vecto…

深度强化学习。介绍。深度 Q 网络 (DQN) 算法

马库斯布赫霍尔茨 一. 引言 深度强化学习的起源是纯粹的强化学习&#xff0c;其中问题通常被框定为马尔可夫决策过程&#xff08;MDP&#xff09;。MDP 由一组状态 S 和操作 A 组成。状态之间的转换使用转移概率 P、奖励 R 和贴现因子 gamma 执行。概率转换P&#xff08;系统动…

SaaS多租户系统架构设计

前言&#xff1a;多租户是SaaS&#xff08;Software-as-a-Service&#xff09;下的一个概念&#xff0c;意思为软件即服务&#xff0c;即通过网络提供软件服务。SaaS平台供应商将应用软件统一部署在自己的服务器上&#xff0c;客户可以根据工作的实际需求&#xff0c;通过互联网…

万字长文解析AQS抽象同步器核心原理(深入阅读AQS源码)

AQS抽象同步器核心原理 在争用激烈的场景下使用基于CAS自旋实现的轻量级锁有两个大的问题&#xff1a; CAS恶性空自旋会浪费大量的CPU资源。在SMP架构的CPU上会导致“总线风暴”。 解决CAS恶性空自旋的有效方式之一是以空间换时间&#xff0c;较为常见的方案有两种&#xff…

ubuntu使用二进制安装mysql常见问题

一、安装mysql完毕后初始化失败 【/usr/local/mysql/bin】./mysqld --usermysql --basedir/usr/local/mysql --datadir/usr/local/mysql/data/ --initialize 输入命令&#xff1a;apt-get install libaio1 libaio-dev 二、初始化成功后重启服务失败 rootyanhong:/usr/local/…