生成一个简单网页demo,使用html、css、JS完成
时间: 2023-05-25 18:03:41 浏览: 67
<!DOCTYPE html>
<html>
<head>
<title>简单网页demo</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
font-size: 40px;
font-weight: normal;
letter-spacing: 2px;
}
nav {
background-color: #ddd;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav li {
margin-right: 20px;
}
nav a {
color: #333;
text-decoration: none;
font-size: 18px;
font-weight: bold;
text-transform: uppercase;
transition: all 0.3s ease;
}
nav a:hover {
color: #fff;
background-color: #333;
padding: 10px;
border-radius: 5px;
}
.content {
width: 1000px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
padding: 20px;
}
.card {
background-color: #fff;
border-radius: 5px;
box-shadow: 0px 2px 10px rgba(0,0,0,0.1);
padding: 20px;
}
.card h2 {
margin-top: 0;
font-size: 24px;
font-weight: bold;
color: #333;
}
.card p {
color: #666;
line-height: 1.5;
}
.card img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
footer {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
position: absolute;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>简单网页demo</h1>
</header>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">产品</a></li>
<li><a href="#">服务</a></li>
<li><a href="#">关于我们</a></li>
<li><a href="#">联系我们</a></li>
</ul>
<form>
<input type="text" placeholder="搜索">
<button type="submit">搜索</button>
</form>
</nav>
<div class="content">
<div class="card">
<img src="https://via.placeholder.com/300x200" alt="占位图">
<h2>卡片标题1</h2>
<p>卡片内容1</p>
<button>了解更多</button>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200" alt="占位图">
<h2>卡片标题2</h2>
<p>卡片内容2</p>
<button>了解更多</button>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200" alt="占位图">
<h2>卡片标题3</h2>
<p>卡片内容3</p>
<button>了解更多</button>
</div>
<div class="card">
<img src="https://via.placeholder.com/300x200" alt="占位图">
<h2>卡片标题4</h2>
<p>卡片内容4</p>
<button>了解更多</button>
</div>
</div>
<footer>
<p>© 2021 简单网页demo - 版权所有</p>
</footer>
</body>
</html>