位置: IT常识 - 正文

【Web 三件套】个人简单博客系统页面搭建(附源码)(后端三件套)

发布时间:2024-01-17
【Web 三件套】个人简单博客系统页面搭建(附源码) 文章目录1. 成品展示2. 知识准备3. 博客系统页面搭建3.1 基本介绍3.2 博客列表页3.3 博客详情页3.4 博客登录页3.5 博客编辑页3.6 公共页面样式3.7 markdown 编辑器引入4. 总结1. 成品展示

推荐整理分享【Web 三件套】个人简单博客系统页面搭建(附源码)(后端三件套),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:网页三件套,web前端三件套,web三大组件作用,microg三件套,web前端三件套,网页三件套,web前端三件套,后端三件套,内容如对您有帮助,希望把文章链接给更多的朋友!

以下为个人搭建的一个简单博客系统页面,以后会不断改进,并且与后端结合,形成一个完整的博客系统

2. 知识准备

该博客系统页面是由 HTML + CSS + JavaScript 搭建的,如果没有了解过这些知识的友友,可以通过本人之前写好的几篇相关文章入门

文章一:《超多动图带你入门 HTML》

文章二:《两万字入门 CSS》

文章三:《JavaScript 入门知识》

文章四:《JavaScript 的数组、函数、对象》

文章五:《JavaScript WebAPI 介绍》

3. 博客系统页面搭建3.1 基本介绍

该博客系统页面现由4个部分组成,分别为:博客列表页、博客详情页、博客登录页、博客编辑页

针对每个页面后面都会进行页面和代码的展示,并且代码中含有个人的注释。为了方便下载使用,下面附上该博客系统页面的 Gitee 链接

Gitee 链接: https://gitee.com/bbbbbge/blog-system

3.2 博客列表页

页面展示:

页面元素 HTML 代码: blog_list.html

<!DOCTYPE html><html lang="en"><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/common.css"> <link rel="stylesheet" href="css/blog_list.css"></head><body> <!-- 导航栏 --> <div class="nav"> <img src="image/log.png" alt=""> <span class="title">我的博客系统</span> <!-- 使用 span 把左右两侧的元素给撑开 --> <span class="spacer"></span> <a href="blog_list.html">主页</a> <a href="blog_edit.html">写博客</a> <a href="blog_login.html">注销</a> </div> <!-- 版心 --> <div class="container"> <!-- 左侧区域,显示用户信息 --> <div class="container-left"> <!-- 用户详情 --> <div class="card"> <!-- 用户的头像 --> <img src="image/head.jpg" alt=""> <!-- 用户名 --> <h3>吞吞吐吐大魔王</h3> <!-- 其它信息 --> <a href="https://blog.csdn.net/weixin_51367845?type=blog">CSDN 地址</a> <a href="#">GitHub 地址</a> <!-- 文章分类 --> <div class="counter"> <span>文章</span> <span>分类</span> </div> <div class="counter"> <span>2</span> <span>1</span> </div> </div> </div> <!-- 右侧区域,显示博客列表 --> <div class="container-right"> <!-- 每个 blog 代表一篇博客 --> <div class="blog"> <div class="title">第一篇博客</div> <div class="date">2022-2-16</div> <div class="desc"> 中国人的性情是喜欢调和折中的,譬如你说,这屋子太暗,须在这里开一个窗,大家一定不允许的。但如果你主张拆掉屋顶他们就来调和,愿意开窗了。 </div> <a href="blog_detail.html" class="detail">查看全文&gt;&gt;</a> </div> <div class="blog"> <div class="title">第二篇博客</div> <div class="date">2022-2-16</div> <div class="desc"> 中国人的性情是喜欢调和折中的,譬如你说,这屋子太暗,须在这里开一个窗,大家一定不允许的。但如果你主张拆掉屋顶他们就来调和,愿意开窗了。 </div> <a href="blog_detail.html" class="detail">查看全文&gt;&gt;</a> </div> </div> </div></body></html>

专属页面样式 CSS 代码: blog_list.css

/* 这个 CSS 专门针对博客列表页来设置样式 */.blog { width: 100%; padding: 10px 20px;}/* 博客的标题 */.blog .title { text-align: center; font-size: 25px; font-weight: 700; padding-top: 10px; padding-bottom: 5px;}/* 博客的日期 */.blog .date { text-align: center; padding-bottom: 10px; color: grey;}/* 博客的描述 */.blog .desc { text-indent: 2em;}/* 查看博客详情的按钮 */.blog .detail { display: block; width: 120px; color: grey; height: 30px; /* 设置边框 */ border: 2px solid grey; /* 文字水平居中 */ text-align: center; /* 文字垂直居中 */ line-height: 30px; /* 去掉下划线 */ text-decoration: none; /* 让按钮来到屏幕中间 */ margin: 10px auto; /* 加上一个过度效果 */ transition: all 1s;}/* 实现鼠标悬停在按钮上时有一个背景色切换的效果 */.blog .detail:hover { background-color: grey; color: white;}3.3 博客详情页

页面展示:

【Web 三件套】个人简单博客系统页面搭建(附源码)(后端三件套)

页面元素 HTML 代码: blog_detail.html

<!DOCTYPE html><html lang="en"><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/common.css"> <link rel="stylesheet" href="css/blog_detail.css"></head><body> <!-- 导航栏 --> <div class="nav"> <img src="image/log.png" alt=""> <span class="title">我的博客系统</span> <!-- 使用 span 把左右两侧的元素给撑开 --> <span class="spacer"></span> <a href="blog_list.html">主页</a> <a href="blog_edit.html">写博客</a> <a href="blog_login.html">注销</a> </div> <!-- 版心 --> <div class="container"> <!-- 左侧区域,显示用户信息 --> <div class="container-left"> <!-- 用户详情 --> <div class="card"> <!-- 用户的头像 --> <img src="image/head.jpg" alt=""> <!-- 用户名 --> <h3>吞吞吐吐大魔王</h3> <!-- 其它信息 --> <a href="https://blog.csdn.net/weixin_51367845?type=blog">CSDN 地址</a> <a href="#">GitHub 地址</a> <!-- 文章分类 --> <div class="counter"> <span>文章</span> <span>分类</span> </div> <div class="counter"> <span>2</span> <span>1</span> </div> </div> </div> <!-- 右侧区域,显示博客列表 --> <div class="container-right"> <!-- 使用这个 div 来放博客内容 --> <div class="blog-content"> <!-- 博客的标题 --> <h3>我的第一篇博客</h3> <!-- 博客的日期 --> <div class="date">2022-2-16</div> <!-- 博客的内容 --> <div class="detail"> <p> 中国人的性情是喜欢调和折中的,譬如你说,这屋子太暗,须在这里开一个窗,大家一定不允许的。但如果你主张拆掉屋顶他们就来调和,愿意开窗了。 </p> <p> 而忽而这些都空虚了,但有时故意地填以没奈何的自欺的希望。希望,希望,用这希望的盾,抗拒那空虚中的暗夜的袭来,虽然盾后面也依然是空虚中的暗夜。 </p> <p> 如果痛苦换来的是结识真理、坚持真理,就应自觉的欣然承受,那时,也只有那时,痛苦穿掘着灵魂的深处,使人受了精神底苦刑而得到创伤,又即从这得伤和养伤和愈合中,得到苦的涤除,而上了苏生的路。 </p> <p> 当我沉默着的时候,我觉得充实;我将开口,同时感到空虚。过去的生命已经死亡。我对于这死亡有大欢喜,因为我借此知道它曾经存活。死亡的生命已经朽腐。我对于这朽腐有大欢喜,因为我借此知道它还非空虚。 </p> </div> </div></body></html>

专属页面样式 CSS 代码: blog_detail.css

/* 这个 CSS 文件是用来放博客详情页的专属样式 */.blog-content { padding: 30px;}/* 博客标题 */.blog-content h3 { text-align: center; padding-top: 40px; padding-bottom: 20px; font-size: 25px;}/* 博客日期 */.blog-content .date { text-align: center; padding-bottom: 10px; color: grey;}/* 博客内容 */.blog-content p { text-indent: 2em; padding: 10px 0;}3.4 博客登录页

页面展示:

页面元素 HTML 代码: blog_login.html

<!DOCTYPE html><html lang="en"><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/common.css"> <link rel="stylesheet" href="css/blog-login.css"></head><body> <!-- 导航栏 --> <div class="nav"> <img src="image/log.png" alt=""> <span class="title">我的博客系统</span> <!-- 使用 span 把左右两侧的元素给撑开 --> <span class="spacer"></span> <a href="blog_list.html">主页</a> <a href="blog_edit.html">写博客</a> <a href="blog_login.html">注销</a> </div> <!-- 登录页面的版心 --> <div class="login-container"> <div class="login-dialog"> <h3>登录</h3> <div class="row1"> <span>用户名</span> <input type="text" id="username"> </div> <div class="row1"> <span>密码</span> <input type="password" id="password"> </div> <div class="row2"> <input type="button" value="提交" id="submit"> </div> </div> </div></body></html>

专属页面样式 CSS 代码: blog_login.css

/* 这个 CSS 文件是放登陆页面的专属样式 *//* 1. 设置版心,让这个版心将页面填充满 *//* 2. 在版心中间位置,设置一个登陆区域 */.login-container { width: 100%; height: calc(100% - 50px); display: flex; justify-content: center; align-items: center;}.login-container .login-dialog { width: 400px; height: 280px; background-color: rgba(255, 255, 255, 0.3); border-radius: 20px;}.login-dialog h3 { text-align: center; padding: 30px; font-size: 25px;}.login-dialog .row1 { height: 40px; display: flex; align-items: center; justify-content: center;}.login-dialog .row2 { height: 40px; display: flex; align-items: center; justify-content: center; padding-top: 30px;}.login-dialog .row1 span { width: 80px; font-weight: 700;}.login-dialog .row1 input { width: 200px; height: 30px; font-size: 15px; padding-left: 10px; background-color: rgba(255, 255, 255, 0.3); /* 去掉边框 */ border: none; /* 去掉轮廓线(选中输入框时,外面的黑边) */ outline: none;}.login-dialog .row2 input { width: 280px; height: 35px; border-radius: 8px; font-size: 20px; background-color: rgba(41, 83, 149, 0.7); border: none;}.login-dialog .row2 input:active { background-color: black; color: white;}3.5 博客编辑页

页面展示:

页面元素 HTML 代码: blog_edit.html

<!DOCTYPE html><html lang="en"><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/common.css"> <link rel="stylesheet" href="css/blog_edit.css"> <!-- 引入依赖 --> <link rel="stylesheet" href="editor.md-master/css/editormd.min.css"> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="editor.md-master/lib/marked.min.js"></script> <script src="editor.md-master/lib/prettify.min.js"></script> <script src="editor.md-master/editormd.js"></script></head><body> <!-- 导航栏 --> <div class="nav"> <img src="image/log.png" alt=""> <span class="title">我的博客系统</span> <!-- 使用 span 把左右两侧的元素给撑开 --> <span class="spacer"></span> <a href="blog_list.html">主页</a> <a href="blog_edit.html">写博客</a> <a href="blog_login.html">注销</a> </div> <!-- 版心 --> <div class="blog-edit-container"> <!-- 标题编辑区 --> <div class="title"> <input type="text" placeholder="在这里写下文章标题" id="title"> <input type="button" value="发布文章" id="submit"> </div> <!-- 内容编辑区 --> <div id="editor"> </div> </div> <script> // 初始化 editor.md let editor = editormd("editor", { // 这里的尺寸必须在这里设置,设置样式会被 editormd 自动覆盖 width: "100%", // 设定编辑高度 height: "500px", // 编辑页中的初始化内容 markdown: "# 在这里写下一篇博客", //指定 editor.md 依赖的插件路径 path: "editor.md-master/lib/" }); </script></body></html>

专属页面样式 CSS 代码: blog_edit.css

/* 这个 CSS 文件放博客编辑的专属样式 *//* 博客编辑页的版心 */.blog-edit-container { width: 1000px; height: calc(100% - 50px); margin: 0 auto;}/* 标题编辑区 */.blog-edit-container .title { margin-top: 20px; width: 100%; height: 60px; display: flex; align-items: center; justify-content: space-between;}.blog-edit-container .title #title { width: 795px; height: 50px; border-radius: 10px; padding-left: 20px; border: none; outline: none; background-color: rgba(41, 83, 149, 0.3); font-size: 15px;}.blog-edit-container .title #submit { width: 200px; height: 50px; border-radius: 10px; border: none; outline: none; background-color: rgba(255, 192 , 153, 0.4); font-size: 20px;}.blog-edit-container .title #submit:active { background-color: rgba(41, 83, 149, 0.3);}#editor { border-radius: 10px; border: none; opacity: 0.7;}3.6 公共页面样式

公共页面样式 CSS 代码: common.css

/* 这个文件里面放4个页面公共的一些样式,比如背景、导航栏等 */* { margin: 0; padding: 0; box-sizing: border-box;}html, body { /* 和父元素的一样高,body 的父亲是 html,html 的父亲是浏览器窗口 */ height: 100%; /* 页面背景 */ background-image: url(../image/background.jpg); background-position: center center; background-repeat: no-repeat; background-size: cover;} /* 导航栏 */.nav { width: 100%; height: 50px; background-color: rgba(50, 50, 50, 0.2); color: #fff; display: flex; justify-content: start; align-items: center;}/* 导航栏中的 log */.nav img { width: 40px; height: 40px; margin-left: 30px; margin-right: 10px;}/* 导航栏中的标题 */.nav .title { width: 120px;}/* 导航栏中的占位符 */.nav .spacer { height: 40px; width: calc(100% - 370px);}/* 导航栏中的链接 */.nav a { width: 60px; margin: 20px; text-decoration: none; color: white;}/* 版心的样式 */.container { height: calc(100% - 50px); width: 1000px; margin: 0 auto; /* 为了让版心里面的子元素能够以左右布局的方式显示,使用 flex 布局 */ display: flex; align-items: center; justify-content: space-between;}/* 左侧区域样式 */.container .container-left { height: 100%; width: 200px;}/* 右侧区域样式 */.container .container-right { height: 100%; width: 795px; background-color: rgba(255, 255, 255, 0.3); border-radius: 20px;}/* 用户信息卡片,也会在多个页面中用到 */.card { background-color: rgba(255, 255, 255, 0.3); border-radius: 20px; padding: 30px;}/* 用户头像 */.card img { width: 140px; height: 140px; border-radius: 50%;}/* 用户名 */.card h3 { text-align: center; padding: 10px 0;}/* 其它信息 */.card a { /* a 标签是行内元素,设置尺寸、边距都可能失效,要转成块级元素 */ display: block; text-decoration: none; text-align: center; color: grey; padding: 3px;}.card .counter { display: flex; justify-content: space-around; font-size: 15px; padding-top: 5px;}3.7 markdown 编辑器引入

在博客编辑页中含有一个 markdown 编辑器,这个是直接引入了一个叫 editor.md 的开源的页面 markdown 编辑器组件,大家也可以使用其它的编辑器组件

引入 editor.md 步骤:

下载 editor.md

大家直接进入该项目的官网进行下载即可

官网地址为:https://pandao.github.io/editor.md/

将下载好的 editor.md 接压缩到该博客项目中

在博客编辑页中引入 editor.md 依赖

<!-- 引入依赖 --><link rel="stylesheet" href="editor.md-master/css/editormd.min.css"><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script><script src="editor.md-master/lib/marked.min.js"></script><script src="editor.md-master/lib/prettify.min.js"></script><script src="editor.md-master/editormd.js"></script>

在博客编辑页中,写个 JS 对 editor.md 进行初始化

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

通过以上步骤,就可以将 editor.md 该 markdown 编辑器引入我们的博客编辑页了

4. 总结

该博客系统页面只是运用前段时间学习的前端知识做出来的一个简单的页面,往后会通过不断的学习来对该博客系统进行补充,期待它的成品!

本文链接地址:https://www.jiuchutong.com/zhishi/298505.html 转载请保留说明!

上一篇:ElementUi 表格自动滚动(elementui表格自定义排序)

下一篇:最新人工智能GPT-4免费简单使用教程(最新人工智能软件chingt)

  • 个人独资企业需要报税吗
  • 销售扣款怎么开票
  • 临时用工的会计分录
  • 鸡蛋普通发票能不能抵扣增值税呢
  • 注册资本转出可以吗
  • 企业所得税年报过了申报期还能修改吗
  • 个税申报本期收入包括社保吗
  • 建筑企业怎么转让
  • 企业季度预缴所得税怎么账务处理
  • 增值税进项税额不予抵扣的项目包括
  • 学校捐赠收入需上交吗
  • 原材料当废品卖怎么处理
  • 税务局即征即退自查报告
  • 通用机打发票上没有税率
  • 取得专用发票不交增值税
  • 国际货运代理免税怎么做账
  • 出租土地收入记什么科目
  • 事业单位购入车辆如何做账
  • 单位存款账户按用途分为
  • 借给其他企业的钱计入什么科目
  • 计提外币借款利息
  • 未开票收入可以不开票吗
  • 电脑管家游戏加速怎么卸载
  • 车船税收费标准2023年多少钱
  • 各部门领料情况,a产品耗用甲材料3200元
  • 计划成本是什么科目
  • 企业筹资付给第三方账户
  • 租赁合同法律风险
  • 同一张发票可以分两次报销吗
  • centos7安装php7.3
  • php上传进度条
  • 营改增之后账务怎么处理
  • 绿萝怎么养才能爬藤
  • 远程访问群晖nas
  • 报销凭证写错了怎么办
  • 一键部署源码
  • css做三角
  • 退回的工伤保险会计分录
  • 收不回的应收账款分录
  • 企业所得税月月交吗
  • 购进原材料用于生产免税产品
  • 免税农产品怎么抵扣进项税
  • rbac权限管理设计
  • 简易计税的增值税税率
  • 小微企业全年营业额不能超过多少
  • 跨境电商财务如何报税
  • 出口收汇核销单的作用
  • 社会团体费怎么做分录
  • 退货销售折让会计分录
  • 长期股权投资成本法转权益法例题
  • 多交了社保
  • 股东退股如何清算
  • 旅游饮食服务企业会计核算的特点
  • win 9x
  • win8系统如何查看电脑型号
  • win10的win+tab
  • wps.exe是什么
  • mis.off c n
  • windos8怎么样
  • win10安装的中文包在哪
  • cocos2d-x引擎
  • ExtJS PropertyGrid中使用Combobox选择值问题
  • jquery实现
  • msoobe命令
  • Node.js中的包管理工具是什么
  • css可继承
  • 提高网页的效率的方法有
  • vue做一个table
  • node.js 教程
  • js上滑翻页
  • 文件夹怎么变成
  • 如何用nodejs搭建服务端
  • JavaScript实现同时调用多个函数的方法
  • 车辆购置税是财行税吗
  • 房子有注册公司可以卖吗
  • 深圳12366接听客服工作怎么样
  • 去地税开个人发票
  • 在发票软件里开出发票第二天打印可以么?
  • 深化体制改革的根本
  • 开票盘是什么意思
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号