…">
当前位置:首页 > CSS

css简单页面制作

2026-03-12 15:33:03CSS

创建HTML文件

新建一个index.html文件,包含基本结构:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简单页面</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <h1>页面标题</h1>
        <nav>
            <ul>
                <li><a href="#">首页</a></li>
                <li><a href="#">关于</a></li>
                <li><a href="#">联系</a></li>
            </ul>
        </nav>
    </header>
    <main>
        <section>
            <h2>内容区域</h2>
            <p>这里是页面主要内容...</p>
        </section>
    </main>
    <footer>
        <p>© 2023 我的网站</p>
    </footer>
</body>
</html>

编写基础CSS样式

创建style.css文件添加基本样式:

css简单页面制作

/* 全局样式 */
body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    color: #333;
}

/* 头部样式 */
header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem;
    text-align: center;
}

nav ul {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: center;
}

nav li {
    margin: 0 15px;
}

nav a {
    color: white;
    text-decoration: none;
}

/* 主体内容样式 */
main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* 页脚样式 */
footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 1rem;
    position: fixed;
    bottom: 0;
    width: 100%;
}

添加响应式设计

在CSS中添加媒体查询实现响应式:

css简单页面制作

@media (max-width: 600px) {
    nav ul {
        flex-direction: column;
    }

    nav li {
        margin: 5px 0;
    }

    main {
        padding: 1rem;
    }
}

增强视觉效果

添加悬停效果和过渡动画:

nav a {
    transition: color 0.3s ease;
}

nav a:hover {
    color: #f39c12;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

添加简单布局组件

创建卡片式布局:

.card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

标签: 页面简单
分享给朋友:

相关文章

vue简单实现

vue简单实现

Vue 简单实现示例 以下是一个使用 Vue.js 创建简单应用的示例,涵盖基本功能如数据绑定、事件处理和组件化。 基础 HTML 结构 <!DOCTYPE html> <html…

vue实现简单的弹窗

vue实现简单的弹窗

Vue实现简单弹窗的方法 使用v-if和v-show控制显示 通过Vue的指令v-if或v-show可以轻松控制弹窗的显示与隐藏。v-if会完全销毁和重建DOM元素,而v-show仅通过CSS的di…

jquery跳转页面

jquery跳转页面

jQuery 跳转页面方法 使用 jQuery 实现页面跳转可以通过多种方式完成,以下是几种常见的方法: 使用 window.location.href 进行跳转 $(document).read…

jquery页面跳转

jquery页面跳转

jQuery 页面跳转方法 使用 jQuery 实现页面跳转可以通过多种方式完成,以下是几种常见的方法: 使用 window.location.href 通过修改 window.location.h…

实现js页面跳转页面跳转页面

实现js页面跳转页面跳转页面

使用 window.location.href 实现跳转 通过修改 window.location.href 属性,可以直接跳转到目标 URL。这种方法会触发页面刷新,并在浏览器历史记录中留下记录。…

实现js页面跳转

实现js页面跳转

使用 window.location.href 通过修改 window.location.href 属性实现跳转,这是最常用的方法: window.location.href = "https://…