用css代码写一个网页
时间: 2023-09-25 19:10:11 浏览: 91
好的,下面是一个简单的用CSS代码写的网页示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>My CSS Webpage</title>
<style>
body {
background-color: #F5F5F5;
font-family: Arial, sans-serif;
font-size: 16px;
color: #333;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #FFF;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
font-size: 32px;
font-weight: normal;
}
nav {
background-color: #FFF;
border-bottom: 1px solid #DDD;
padding: 10px;
text-align: center;
}
nav a {
color: #333;
display: inline-block;
margin: 0 10px;
text-decoration: none;
}
nav a:hover {
color: #666;
}
section {
padding: 20px;
margin: 20px;
background-color: #FFF;
border: 1px solid #DDD;
}
footer {
background-color: #333;
color: #FFF;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>
<header>
<h1>My CSS Webpage</h1>
</header>
<nav>
<a href="#">Home</a>
<a href="#">About Us</a>
<a href="#">Contact</a>
</nav>
<section>
<h2>Welcome to My CSS Webpage</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec auctor, elit vel eleifend gravida, eros magna pellentesque urna, at tristique nunc enim ut magna.</p>
<p>Nulla bibendum, nunc vel congue tincidunt, nisl quam sodales massa, ac hendrerit purus odio nec sem. Sed hendrerit, lorem eu euismod fringilla, purus eros mollis velit, sit amet cursus nunc neque vel lectus.</p>
</section>
<footer>
<p>© 2021 My CSS Webpage</p>
</footer>
</body>
</html>
```
这个网页包括一个顶部的标题栏、一个导航栏、一个正文区域和一个底部的版权声明。CSS代码用于设置网页的样式,包括背景颜色、字体、颜色、边框、内边距等等。
阅读全文