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

html+css网页设计

作者:凌傲天   发布日期:2026-01-09   浏览:67

<!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: #333;
            color: #fff;
            text-align: center;
            padding: 1rem;
        }

        nav {
            display: flex;
            justify-content: center;
            background-color: #444;
        }

        nav a {
            color: #fff;
            padding: 1rem;
            text-decoration: none;
            display: inline-block;
        }

        nav a:hover {
            background-color: #555;
        }

        .container {
            width: 80%;
            margin: 2rem auto;
            background-color: #fff;
            padding: 1rem;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        footer {
            text-align: center;
            padding: 1rem;
            background-color: #333;
            color: #fff;
            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>

    <div class="container">
        <h2>HTML + CSS 网页设计示例</h2>
        <p>这是一个简单的 HTML 和 CSS 示例,展示了如何创建一个基本的网页布局。</p>
    </div>

    <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 布局使导航链接水平居中,并设置背景颜色。
    • nav a: 设置导航链接的颜色、内边距和悬停效果。
    • .container: 设置内容区域的宽度、外边距、背景颜色和阴影效果。
    • footer: 设置页脚的文本对齐、背景颜色、文本颜色和固定在页面底部。

这个示例代码展示了一个简单的 HTML 和 CSS 组合,用于创建一个具有基本布局和样式的网页。

上一篇:html a标签

下一篇:html onplay

大家都在看

静态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 中文站