• 简单的博客系统(CSS+HTML)


    目录

    一、简单介绍

    1、博客系统简介

    二、博客列表页

    三、用户登录页

     四、博客详情页

     五、博客编辑页

    六、相关代码


    一、简单介绍

    1、博客系统简介

    用户登录页场景

    博客列表页场景

    博客详情页场景

    博客编辑页场景

    每个场景都是由镀多个功能区组成的

    二、博客列表页

    1. html>
    2. <html lang="zh-hans">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>博客列表title>
    6. <link rel="stylesheet" href="./css/List.css">
    7. head>
    8. <body>
    9. <div class="导航栏">
    10. <div class="导航栏左边">
    11. <div class="logo-shell">
    12. <img class="logo" src="./img/logo.jpg">
    13. div>
    14. 我的博客系统
    15. div>
    16. <div class="导航栏右边">
    17. <a href="/List.html">主页a>
    18. <a href="/edit.html">写博客a>
    19. <a href="/login.html">注销a>
    20. div>
    21. div>
    22. <div class="下面区域">
    23. <div class="用户信息展示">
    24. <div class="头像展示区">
    25. <img src="./img/avatar.jpg">
    26. div>
    27. <div class="用户名称">小熊吃糖div>
    28. <div class="git地址">
    29. <a href="https://gitee.com/ren-xiaoxiong">gitee 地址a>
    30. div>
    31. <div class="统计信息">
    32. <div class="文章数量区域">
    33. <div>文章div>
    34. <div class="文章数量">2div>
    35. div>
    36. <div class="分类数量区域">
    37. <div>分类div>
    38. <div class="分类数量">2div>
    39. div>
    40. div>
    41. div>
    42. <div class="博客列表展示">
    43. <div class="博客项">
    44. <h3 class="博客标题">我的第一篇博客h3>
    45. <p class="发表日期">2022-08-09 09:31:28p>
    46. <p class="简介信息">从今天起, 我要认真敲代码. Lorem ipsum, dolor sit amet consectetur adipisicing elit.
    47. Cum distinctio ullam eum ut veroab laborum numquam tenetur est in dolorum a sint, assumenda adipisci
    48. similique quaerat vel. Facere,et.p>
    49. <div class="按钮区域"><a href="/edit.html">查看全文 >>a>div>
    50. div>
    51. <div class="博客项">
    52. <h3 class="博客标题">我的第二篇博客h3>
    53. <p class="发表日期">2022-08-11 16:31:35p>
    54. <p class="简介信息">从今天起, 我要认真敲代码. Lorem ipsum, dolor sit amet consectetur adipisicing elit.
    55. Cum distinctio ullam eum ut veroab laborum numquam tenetur est in dolorum a sint, assumenda adipisci
    56. similique quaerat vel. Facere,et.p>
    57. <div class="按钮区域"><a href="/edit.html">查看全文 >>a>div>
    58. div>
    59. div>
    60. div>
    61. body>
    62. html>
    1. @import "NavigationBar.css";
    2. .下面区域 {
    3. min-height: calc(100vh - 50px);
    4. /* background-color: #215877; */
    5. display: flex;
    6. align-items: flex-start;
    7. justify-content: space-between;
    8. padding: 8px 220px;
    9. }
    10. .用户信息展示 {
    11. width: 220px;
    12. background-color: rgba(255, 255, 255, .6);
    13. border-radius: 8px;
    14. padding: 12px 0;
    15. box-shadow: 0 0 5px #000;
    16. }
    17. .用户信息展示 {
    18. display: flex;
    19. flex-direction: column;
    20. gap: 12px;
    21. align-items: center;
    22. justify-content: space-between;
    23. }
    24. .头像展示区 {
    25. width: 100px;
    26. height: 100px;
    27. border-radius: 50%;
    28. overflow: hidden;
    29. }
    30. .头像展示区 img {
    31. width: 100px;
    32. }
    33. .用户名称 {
    34. font-size: 24px;
    35. font-weight: 700;
    36. }
    37. .git地址 a {
    38. color: #ea7a7a;
    39. font-size: 14px;
    40. font-style: italic;
    41. }
    42. .统计信息 {
    43. display: flex;
    44. align-items: stretch;
    45. justify-content: space-between;
    46. gap: 18px; /*间隔*/
    47. }
    48. .文章数量区域,
    49. .分类数量区域 {
    50. display: flex;
    51. flex-direction: column;
    52. align-items: center;
    53. justify-content: space-between;
    54. gap: 8px;
    55. }
    56. .博客列表展示 {
    57. min-height: calc(100vh - 50px - 8px - 8px);
    58. width: calc(100% - 220px - 8px);
    59. background-color: rgba(255, 255, 255, .6);
    60. border-radius: 8px;
    61. box-shadow: 0 0 5px #000;
    62. padding: 8px;
    63. }
    64. .博客项{
    65. width: 100%;
    66. margin: 12px;
    67. display: flex;
    68. flex-direction: column;
    69. align-items: stretch;
    70. justify-content: space-between;
    71. gap: 8px;
    72. }
    73. .博客标题{
    74. text-align: center;
    75. font-size: 24px;
    76. font-weight: 900;
    77. }
    78. .发表日期{
    79. text-align: center;
    80. color: #3ff159;
    81. }
    82. .简介信息{
    83. text-indent: 2em;
    84. font-size: 16px;
    85. }
    86. .按钮区域{
    87. display: flex;
    88. justify-content: center;
    89. }
    90. .博客项 a{
    91. width: 180px;
    92. height: 40px;
    93. line-height: 40px;
    94. text-align: center;
    95. font-size: 16px;
    96. color: black;
    97. text-decoration: none;
    98. border: 2px solid #000;
    99. }

     导航栏的CSS

    1. * {
    2. margin: 0;
    3. padding: 0;
    4. box-sizing: border-box;
    5. font-family: '宋体', fangsong;
    6. font-size: 18px;
    7. }
    8. body {
    9. width: 100%;
    10. min-height: 100vh;
    11. /* background-color: #f519e3; */
    12. background-image: url(../img/background.jpg);
    13. background-size: cover;
    14. background-position: 0 -80px; /* 大家如果自己找的背景图,可能要修改这里 */
    15. background-repeat: no-repeat;
    16. background-attachment: fixed;
    17. }
    18. .导航栏 {
    19. width: 100%;
    20. height: 50px;
    21. /* background-color: #95c766; */
    22. background-color: rgba(154, 223, 223, .5);
    23. display: flex;
    24. align-items: stretch;
    25. justify-content: space-between;
    26. padding: 0 12px;
    27. }
    28. .导航栏左边, .导航栏右边 {
    29. display: flex;
    30. align-items: center;
    31. justify-content: space-between;
    32. }
    33. .导航栏左边 > *,
    34. .导航栏右边 > * {
    35. margin: 0 16px;
    36. }
    37. .logo-shell {
    38. width: 36px;
    39. height: 36px;
    40. border-radius: 50%;
    41. overflow: hidden;
    42. }
    43. .logo {
    44. width: 36px;
    45. height: 36px;
    46. }
    47. .导航栏 {
    48. color: #fff;
    49. }
    50. .导航栏 a {
    51. color: #fff;
    52. text-decoration: none;
    53. }

    三、用户登录页

    1. html>
    2. <html lang="zh-hans">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>博客列表title>
    6. <link rel="stylesheet" href="./css/login.css">
    7. head>
    8. <body>
    9. <div class="导航栏">
    10. <div class="导航栏左边">
    11. <div class="logo-shell">
    12. <img class="logo" src="./img/logo.jpg">
    13. div>
    14. 我的博客系统
    15. div>
    16. <div class="导航栏右边">
    17. <a href="/List.html">主页a>
    18. <a href="/edit.html">写博客a>
    19. <a href="/login.html">注销a>
    20. div>
    21. div>
    22. <div class="下面区域">
    23. <form method="post" action="/login.do">
    24. <h1>登录h1>
    25. <label>
    26. 用户名
    27. <input type="text" name="username">
    28. label>
    29. <label>
    30. 密码
    31. <input type="password" name="password">
    32. label>
    33. <button>提交button>
    34. form>
    35. div>
    36. body>
    37. html>
    1. @import "NavigationBar.css";
    2. .下面区域{
    3. min-height: calc(100vh - 50px);
    4. display: flex;
    5. justify-content: center;
    6. align-items: center;
    7. }
    8. .下面区域 form{
    9. background-color: rgba(255,255,255,.6);
    10. padding: 16px;
    11. border-radius: 8px;
    12. box-shadow: 0 0 5px #000;
    13. width: 600px ;
    14. display: flex;
    15. flex-direction: column;
    16. align-items: stretch;
    17. justify-content: space-between;
    18. }
    19. .下面区域 form > *{
    20. margin: 12px;
    21. }
    22. .下面区域 h1{
    23. text-align: center;
    24. }
    25. .下面区域 label{
    26. display: flex;
    27. justify-content: space-between;
    28. align-items: center;
    29. }
    30. .下面区域 input{
    31. width: 400px;
    32. border: none;
    33. outline: none;
    34. border-radius: 4px;
    35. }
    36. .下面区域 input,
    37. .下面区域 button{
    38. height: 30px;
    39. line-height: 30px;
    40. }
    41. .下面区域 button{
    42. background-color: #91e59e;
    43. border: none;
    44. color: #ffffff;
    45. }

     四、博客详情页

    和博客列表页类似,只需要更换内容即可

    1. html>
    2. <html lang="zh-hans">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>博客列表页title>
    6. <link rel="stylesheet" href="./css/details.css">
    7. head>
    8. <body>
    9. <div class="导航栏">
    10. <div class="导航栏左边">
    11. <div class="logo-shell">
    12. <img class="logo" src="./img/logo.jpg">
    13. div>
    14. 我的博客系统
    15. div>
    16. <div class="导航栏右边">
    17. <a href="/List.html">主页a>
    18. <a href="/edit.html">写博客a>
    19. <a href="/login.html">注销a>
    20. div>
    21. div>
    22. <div class="下面区域">
    23. <div class="用户信息展示">
    24. <div class="头像展示区">
    25. <img src="./img/avatar.jpg">
    26. div>
    27. <div class="用户名称">小熊吃糖div>
    28. <div class="git地址">
    29. <a href="https://gitee.com/ren-xiaoxiong">gitee 地址a>
    30. div>
    31. <div class="统计信息">
    32. <div class="文章数量区域">
    33. <div>文章div>
    34. <div class="文章数量">2div>
    35. div>
    36. <div class="分类数量区域">
    37. <div>分类div>
    38. <div class="分类数量">2div>
    39. div>
    40. div>
    41. div>
    42. <div class="博客列表展示">
    43. <div class="博客项">
    44. <h3 class="博客标题">我的第一篇博客h3>
    45. <p class="发表日期">2022-08-09 09:31:28p>
    46. <p class="简介信息">从今天起, 我要认真敲代码. Lorem ipsum, dolor sit amet consectetur adipisicing elit.
    47. Cum distinctio ullam eum ut veroab laborum numquam tenetur est in dolorum a sint, assumenda adipisci
    48. similique quaerat vel. Facere,et.p>
    49. <div class="按钮区域"><a href="/details.html">查看全文 >>a>div>
    50. div>
    51. <div class="博客项">
    52. <h3 class="博客标题">我的第二篇博客h3>
    53. <p class="发表日期">2022-08-11 16:31:35p>
    54. <p class="简介信息">从今天起, 我要认真敲代码. Lorem ipsum, dolor sit amet consectetur adipisicing elit.
    55. Cum distinctio ullam eum ut veroab laborum numquam tenetur est in dolorum a sint, assumenda adipisci
    56. similique quaerat vel. Facere,et.p>
    57. <div class="按钮区域"><a href="/details.html">查看全文 >>a>div>
    58. div>
    59. div>
    60. div>
    61. body>
    62. html>
    @import "List.css";

     五、博客编辑页

    我们导入别人已经写好的开源编辑器,引入 editor.md

    官网参见: https://pandao.github.io/editor.md/

    首先引入需要的文件

    1. <script src="./js/jquery.min.js">script>
    2. <script src="./editor.md/lib/marked.min.js">script>
    3. <script src="./editor.md/lib/prettify.min.js">script>
    4. <script src="./editor.md/editormd.js">script>

    需要初始化编辑器 

    1. // 初始化编辑器
    2. let editor = editormd("编辑器", {
    3. // 这里的尺寸必须在这里设置. 设置样式会被 editormd 自动覆盖掉.
    4. width: "100%",
    5. // 高度 100% 意思是和父元素一样高. 要在父元素的基础上去掉标题编辑区的高度
    6. height: "calc(100% - 50px)",
    7. // 编辑器中的初始内容
    8. markdown: "# 在这里写下一篇博客",
    9. // 指定 editor.md 依赖的插件路径
    10. path: "./editor.md/lib/"
    11. });

    1. html>
    2. <html lang="zh-hans">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>博客编辑页title>
    6. <link rel="stylesheet" href="./css/edit.css">
    7. <link rel="stylesheet" href="./editor.md/css/editormd.min.css">
    8. head>
    9. <body>
    10. <div class="导航栏">
    11. <div class="导航栏左边">
    12. <div class="logo-shell">
    13. <img class="logo" src="./img/logo.jpg">
    14. div>
    15. 我的博客系统
    16. div>
    17. <div class="导航栏右边">
    18. <a href="/List.html">主页a>
    19. <a href="/edit.html">写博客a>
    20. <a href="/login.html">注销a>
    21. div>
    22. div>
    23. <div class="下面区域">
    24. <form method="post" action="/edit.do">
    25. <div class="首行" >
    26. <input type="text" name="title" placeholder="博客标题">
    27. <input type="text" name="category" placeholder="博客分类">
    28. <button class="按钮" >发布文章button>
    29. div>
    30. <div class="editor" id="编辑器">
    31. div>
    32. form>
    33. div>
    34. <script src="./js/jquery.min.js">script>
    35. <script src="./editor.md/lib/marked.min.js">script>
    36. <script src="./editor.md/lib/prettify.min.js">script>
    37. <script src="./editor.md/editormd.js">script>
    38. <script>
    39. // 初始化编辑器
    40. let editor = editormd("编辑器", {
    41. // 这里的尺寸必须在这里设置. 设置样式会被 editormd 自动覆盖掉.
    42. width: "100%",
    43. // 高度 100% 意思是和父元素一样高. 要在父元素的基础上去掉标题编辑区的高度
    44. height: "calc(100% - 50px)",
    45. // 编辑器中的初始内容
    46. markdown: "# 在这里写下一篇博客",
    47. // 指定 editor.md 依赖的插件路径
    48. path: "./editor.md/lib/"
    49. });
    50. script>
    51. body>
    52. html>
    1. @import "NavigationBar.css";
    2. .下面区域{
    3. width: 1200px;
    4. min-height: calc(100vh - 50px);
    5. margin: 8px auto;
    6. }
    7. .下面区域 form{
    8. width: 100%;
    9. height: 100%;
    10. display: flex;
    11. flex-direction: column;
    12. align-items: stretch;
    13. justify-content: space-between;
    14. gap: 12px;
    15. }
    16. .下面区域 form .首行 input{
    17. width: 300px;
    18. border: none;
    19. outline: none;
    20. height: 30px;
    21. line-height: 30px;
    22. }
    23. .下面区域 form .首行{
    24. display: flex;
    25. justify-content: space-between;
    26. align-items: stretch;
    27. }
    28. .下面区域 form .editor{
    29. min-height: calc(100vh - 100px);
    30. }
    31. .下面区域 form .首行 input button{
    32. width: 220px;
    33. height: 30px;
    34. }
    35. .下面区域 form .首行 .按钮{
    36. background-color: #43d0d0;
    37. }

    六、相关代码

    blog: 使用css+html做的简单博客页面https://gitee.com/ren-xiaoxiong/blog

  • 相关阅读:
    接口测试 —— Requests库GET请求
    类与对象(一)----什么是类和对象
    【C++】多态 — 多态的原理 (下篇)
    阿里云 linux 的nginx 配置uni-app的H5前端项目vue,后端接口阿里云。
    pointnet点云分类,matlab,程序可用,修改一个参数
    Oracle数据库中索引的基本使用
    第2章:类加载子系统 详解
    php+mysql计算机公共课在线学习网站
    C++编译静态成员函数报错: “osgGA::DriveManipulator::setEye”: 非静态成员函数的非法调用
    DNS解析中CNAME和MX记录冲突
  • 原文地址:https://blog.csdn.net/m0_68989458/article/details/126272523