css简单页面制作
CSS简单页面制作步骤
创建HTML文件
新建一个index.html文件,写入基础HTML结构:
<!DOCTYPE html>
<html>
<head>
<title>简单页面</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>欢迎来到我的网站</h1>
</header>
<main>
<p>这是一个使用CSS制作的简单页面示例。</p>
</main>
<footer>
<p>© 2023 我的网站</p>
</footer>
</body>
</html>
创建CSS文件
新建styles.css文件,添加基础样式:

body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
color: #333;
}
header {
background: #4CAF50;
color: white;
padding: 1rem;
text-align: center;
}
main {
padding: 2rem;
}
footer {
background: #333;
color: white;
text-align: center;
padding: 1rem;
position: fixed;
bottom: 0;
width: 100%;
}
添加响应式设计 在CSS文件中加入媒体查询,使页面适配不同设备:

@media (max-width: 600px) {
header h1 {
font-size: 1.5rem;
}
main {
padding: 1rem;
}
}
增强视觉效果 添加一些交互效果提升用户体验:
a {
color: #4CAF50;
text-decoration: none;
transition: color 0.3s;
}
a:hover {
color: #45a049;
}
button {
background: #4CAF50;
color: white;
border: none;
padding: 0.5rem 1rem;
cursor: pointer;
border-radius: 4px;
}
button:hover {
background: #45a049;
}
布局技巧 使用Flexbox创建简单布局:
.container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.item {
flex: 1 1 200px;
margin: 0.5rem;
padding: 1rem;
border: 1px solid #ddd;
border-radius: 4px;
}






