我需要一个用HTML5加css3加js制作一个关于杭州的土特产品并图文混排,使用一些动画效果的网页代码
时间: 2024-03-14 15:48:37 浏览: 71
好的,下面是一个简单的HTML5、CSS3、JavaScript制作的关于杭州土特产品的网页代码,包含了图文混排和一些动画效果:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>杭州土特产品</title>
<style>
body {
background-color: #e6e6e6;
margin: 0;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.product {
width: 30%;
margin-bottom: 30px;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
transition: transform 0.3s ease-in-out;
cursor: pointer;
}
.product:hover {
transform: scale(1.05);
}
.product img {
width: 100%;
height: auto;
object-fit: cover;
}
.product h3 {
font-size: 24px;
margin: 20px;
text-align: center;
}
.product p {
font-size: 16px;
margin: 0 20px 20px 20px;
text-align: justify;
line-height: 1.5;
height: 100px;
overflow: hidden;
}
.product:hover p {
height: auto;
}
.product-info {
position: absolute;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.8);
color: #fff;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
.product:hover .product-info {
opacity: 1;
}
.product-info h3 {
font-size: 32px;
margin-bottom: 10px;
}
.product-info p {
font-size: 16px;
margin: 0 20px 20px 20px;
text-align: center;
line-height: 1.5;
}
@keyframes slide-in {
from {
transform: translateX(-100%);
}
to {
transform: translateX(0);
}
}
.header {
background-color: #fff;
padding: 20px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
top: 0;
left: 0;
right: 0;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
z-index: 1;
}
.logo {
font-size: 24px;
font-weight: bold;
text-transform: uppercase;
color: #333;
}
.menu {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: -200px;
height: 100vh;
background-color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
transition: left 0.3s ease-in-out;
z-index: 1;
}
.menu.open {
left: 0;
}
.menu a {
font-size: 24px;
font-weight: bold;
color: #333;
margin: 10px;
transition: color 0.3s ease-in-out;
}
.menu a:hover {
color: #f00;
}
.menu .close {
font-size: 36px;
position: absolute;
top: 20px;
right: 20px;
cursor: pointer;
}
@media (max-width: 768px) {
.product {
width: 45%;
}
.header {
padding: 10px;
}
.logo {
font-size: 16px;
}
.menu {
left: -100%;
}
.menu.open {
left: 0;
}
}
</style>
</head>
<body>
<header class="header">
<div class="logo">杭州土特产品</div>
<div class="menu-toggle">☰</div>
<nav class="menu">
<div class="close">×</div>
<a href="#">首页</a>
<a href="#">产品介绍</a>
<a href="#">联系我们</a>
</nav>
</header>
<div class="container">
<div class="product">
<img src="https://picsum.photos/id/237/300/200" alt="">
<div class="product-info">
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<div class="product">
<img src="https://picsum.photos/id/238/300/200" alt="">
<div class="product-info">
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<div class="product">
<img src="https://picsum.photos/id/239/300/200" alt="">
<div class="product-info">
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<div class="product">
<img src="https://picsum.photos/id/240/300/200" alt="">
<div class="product-info">
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<div class="product">
<img src="https://picsum.photos/id/241/300/200" alt="">
<div class="product-info">
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<div class="product">
<img src="https://picsum.photos/id/242/300/200" alt="">
<div class="product-info">
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
<h3>产品名称</h3>
<p>这是一段产品描述</p>
</div>
</div>
<script>
const menuToggle = document.querySelector('.menu-toggle');
const menu = document.querySelector('.menu');
const close = document.querySelector('.close');
menuToggle.addEventListener('click', function() {
menu.classList.add('open');
});
close.addEventListener('click', function() {
menu.classList.remove('open');
});
</script>
</body>
</html>
```
你可以在此基础上进行调整和修改,以符合你的实际需求。
阅读全文