html和css静态网页制作
时间: 2023-07-03 12:12:17 浏览: 81
HTML 和 CSS 都是用于网页制作的语言,HTML 用于定义网页的内容、结构和布局,CSS 用于定义网页的样式和外观。下面是一个简单的 HTML 和 CSS 静态网页制作示例:
HTML 代码:
```
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<h1>My Website</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
</header>
<main>
<section class="hero">
<h2>Welcome to My Website</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="#" class="btn">Learn More</a>
</section>
<section>
<h3>About Us</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nulla sed convallis lacinia, dui libero bibendum quam, non semper sapien leo eu odio.</p>
</section>
<section>
<h3>Contact Us</h3>
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br>
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea><br>
<input type="submit" value="Send">
</form>
</section>
</main>
<footer>
<p>©2021 My Website</p>
</footer>
</body>
</html>
```
CSS 代码:
```
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
nav ul li {
display: inline-block;
margin-right: 20px;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
.hero {
background-image: url("hero.jpg");
background-size: cover;
background-position: center;
height: 500px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
color: #fff;
}
.hero h2 {
font-size: 3rem;
margin: 0;
}
.hero p {
font-size: 1.5rem;
margin: 20px 0;
}
.btn {
background-color: #fff;
color: #333;
padding: 10px 20px;
border-radius: 4px;
text-decoration: none;
}
section {
max-width: 800px;
margin: 0 auto;
padding: 40px;
}
section h3 {
font-size: 2rem;
margin-top: 0;
}
form label {
display: block;
margin-bottom: 5px;
}
form input,
form textarea {
padding: 10px;
border-radius: 4px;
border: none;
margin-bottom: 20px;
}
form input[type="submit"] {
background-color: #333;
color: #fff;
border: none;
cursor: pointer;
}
footer {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
```
这个网页包含了一个头部区域、导航菜单、主要内容区域和页脚。头部区域包含了网站的标题和导航菜单,主要内容区域包含了三个部分:一个带有大图的主页区域、一个简介页面和一个联系我们的表单页面。CSS 文件包含了网站的样式,包括了字体、颜色、布局和背景图像等。整个网页的样式和布局可以通过修改 CSS 文件来进行修改。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)