Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

html css网页制作

作者:哥伤不起   发布日期:2026-04-16   浏览:39

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML CSS 网页制作示例</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;
        }

        /* 设置主要内容区域样式 */
        main {
            padding: 20px;
            text-align: center;
        }

        /* 设置页脚样式 */
        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="#services">服务</a>
        <a href="#contact">联系我们</a>
    </nav>

    <!-- 主要内容 -->
    <main>
        <h2>这是一个简单的 HTML 和 CSS 示例</h2>
        <p>使用 HTML 和 CSS 可以创建结构化和美观的网页。</p>
    </main>

    <!-- 页脚 -->
    <footer>
        <p>&copy; 2023 我的公司. 保留所有权利.</p>
    </footer>
</body>
</html>

解释说明

  1. HTML 结构:

    • <!DOCTYPE html>: 声明文档类型为 HTML5。
    • <html lang="zh-CN">: 设置网页语言为中文。
    • <head>: 包含元数据(如字符编码、视口设置、标题等)和样式表。
    • <body>: 包含网页的主要内容。
  2. CSS 样式:

    • body: 设置全局字体、背景颜色、边距和填充。
    • header: 设置头部的背景颜色、文本颜色、内边距和文本对齐方式。
    • nav: 使用 Flexbox 布局使导航链接居中,并设置背景颜色和文本颜色。
    • main: 设置主要内容区域的内边距和文本对齐方式。
    • footer: 设置页脚的背景颜色、文本颜色、文本对齐方式和固定位置。
  3. HTML 内容:

    • <header>: 包含网页的标题。
    • <nav>: 包含导航链接。
    • <main>: 包含网页的主要内容。
    • <footer>: 包含页脚信息。

上一篇:html文档

下一篇:html表格代码大全

大家都在看

静态html源码

404 html

ios打开html

nginx访问不到html

html 符号

colspan在html中是什么意思

怎么将网页另存为html

xml转html

html时间代码

html localstorage

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站