<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>个人博客</title>
<style>
/* 简单的样式,使页面看起来更美观 */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
header {
background-color: #4CAF50;
color: white;
padding: 10px 0;
text-align: center;
}
nav {
display: flex;
justify-content: center;
background-color: #333;
}
nav a {
color: white;
padding: 14px 20px;
text-decoration: none;
text-align: center;
}
nav a:hover {
background-color: #ddd;
color: black;
}
.container {
padding: 20px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px 0;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>欢迎来到我的个人博客</h1>
</header>
<nav>
<a href="#home">首页</a>
<a href="#about">关于我</a>
<a href="#articles">文章</a>
<a href="#contact">联系我</a>
</nav>
<div class="container">
<h2>最新文章</h2>
<article>
<h3>文章标题1</h3>
<p>这是第一篇文章的内容。你可以在这里写一些有趣的事情。</p>
</article>
<article>
<h3>文章标题2</h3>
<p>这是第二篇文章的内容。你可以在这里写一些有趣的事情。</p>
</article>
</div>
<footer>
<p>© 2023 我的个人博客</p>
</footer>
</body>
</html>
HTML结构:
<!DOCTYPE html>:声明文档类型为HTML5。<html lang="zh-CN">:指定语言为简体中文。<head>:包含元数据、字符集声明、视口设置和页面标题。<body>:页面的主要内容部分。CSS样式:
<style>标签)来定义页面的基本样式,包括字体、背景颜色、布局等。header、nav、footer等元素分别定义了页面的头部、导航栏和底部区域。nav a定义了导航链接的样式,并设置了悬停效果。页面内容:
header中包含一个欢迎标题。nav中包含四个导航链接,分别指向不同的页面或锚点。container中包含两个示例文章,每个文章有一个标题和一段简短的内容。footer中包含版权信息,并固定在页面底部。这个代码提供了一个简单的个人博客网页模板,你可以根据需要进行修改和扩展。
上一篇:html代码在线运行
下一篇:html下拉菜单
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站