用html,css,js写一个图书展示主页
时间: 2023-07-16 16:14:06 浏览: 65
好的,以下是一个简单的图书展示主页的HTML、CSS和JS代码示例:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>图书展示主页</title>
<link rel="stylesheet" type="text/css" 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>
<li><a href="#">关于我们</a></li>
</ul>
</nav>
</header>
<main>
<section class="book">
<img src="https://via.placeholder.com/150" alt="书籍封面">
<h2>书籍标题</h2>
<p>书籍描述</p>
<button>查看详情</button>
</section>
<section class="book">
<img src="https://via.placeholder.com/150" alt="书籍封面">
<h2>书籍标题</h2>
<p>书籍描述</p>
<button>查看详情</button>
</section>
<section class="book">
<img src="https://via.placeholder.com/150" alt="书籍封面">
<h2>书籍标题</h2>
<p>书籍描述</p>
<button>查看详情</button>
</section>
</main>
<footer>
<p>© 2021 图书展示主页</p>
</footer>
<script src="script.js"></script>
</body>
</html>
```
CSS代码:
```css
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
}
nav ul {
margin: 0;
padding: 0;
list-style-type: none;
}
nav li {
display: inline-block;
margin-right: 20px;
}
nav li:last-child {
margin-right: 0;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
max-width: 800px;
margin: 0 auto;
padding: 20px;
display: flex;
flex-wrap: wrap;
}
.book {
flex-basis: 30%;
margin: 1%;
background-color: #f2f2f2;
padding: 20px;
text-align: center;
}
.book img {
display: block;
margin: 0 auto;
}
.book h2 {
margin-top: 10px;
margin-bottom: 5px;
}
.book p {
margin-top: 0;
}
button {
background-color: #333;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
margin-top: 10px;
cursor: pointer;
}
button:hover {
background-color: #444;
}
```
JS代码:
```js
// 可以在这里添加一些交互效果或动态数据
```
阅读全文