写一个家乡介绍的html代码,要有动画,界面清新,内容丰富
时间: 2024-03-13 21:45:02 浏览: 65
很高兴回答你的问题,以下是一个简单的家乡介绍的html代码,带有动画效果,界面清新,内容丰富。
```html
<!DOCTYPE html>
<html>
<head>
<title>家乡介绍</title>
<style>
body {
background: #f2f2f2; /* 设置背景颜色 */
font-family: Arial, sans-serif;
}
h1 {
font-size: 48px;
text-align: center;
margin-top: 50px;
}
.container {
width: 80%;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
margin-top: 50px;
margin-bottom: 50px;
}
.card {
width: 30%;
margin-bottom: 30px;
border-radius: 10px;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.1);
background: #fff;
position: relative;
padding: 30px;
overflow: hidden;
cursor: pointer;
}
.card:hover .overlay {
height: 100%;
}
.card img {
width: 100%;
height: auto;
margin-bottom: 20px;
}
.card h2 {
font-size: 24px;
margin-bottom: 10px;
color: #333;
font-weight: 600;
}
.card p {
font-size: 16px;
line-height: 1.5;
color: #666;
margin-bottom: 20px;
}
.overlay {
width: 100%;
height: 0;
position: absolute;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
transition: height 0.3s ease-in-out;
padding: 20px;
box-sizing: border-box;
color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.overlay h3 {
font-size: 24px;
margin-bottom: 10px;
color: #fff;
font-weight: 600;
}
.overlay p {
font-size: 16px;
line-height: 1.5;
color: #fff;
margin-bottom: 20px;
}
.overlay a {
background: #fff;
color: #333;
padding: 10px 20px;
border-radius: 5px;
text-decoration: none;
font-size: 16px;
font-weight: 600;
transition: background 0.3s ease-in-out;
margin-top: 20px;
}
.overlay a:hover {
background: #333;
color: #fff;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.fade-in {
animation: fadeIn 1s ease-in-out;
}
@keyframes slideInLeft {
from { transform: translateX(-100%); }
to { transform: translateX(0); }
}
.slide-in-left {
animation: slideInLeft 0.5s ease-in-out;
}
@keyframes slideInRight {
from { transform: translateX(100%); }
to { transform: translateX(0); }
}
.slide-in-right {
animation: slideInRight 0.5s ease-in-out;
}
</style>
</head>
<body>
<h1>我的家乡</h1>
<div class="container">
<div class="card fade-in slide-in-left">
<img src="https://picsum.photos/id/1000/400/300" alt="景点1">
<h2>景点1</h2>
<p>介绍景点1的相关信息。</p>
<div class="overlay">
<h3>景点1</h3>
<p>更加详细的介绍景点1。</p>
<a href="#">了解更多</a>
</div>
</div>
<div class="card fade-in">
<img src="https://picsum.photos/id/1001/400/300" alt="景点2">
<h2>景点2</h2>
<p>介绍景点2的相关信息。</p>
<div class="overlay">
<h3>景点2</h3>
<p>更加详细的介绍景点2。</p>
<a href="#">了解更多</a>
</div>
</div>
<div class="card fade-in slide-in-right">
<img src="https://picsum.photos/id/1002/400/300" alt="景点3">
<h2>景点3</h2>
<p>介绍景点3的相关信息。</p>
<div class="overlay">
<h3>景点3</h3>
<p>更加详细的介绍景点3。</p>
<a href="#">了解更多</a>
</div>
</div>
<div class="card fade-in slide-in-left">
<img src="https://picsum.photos/id/1003/400/300" alt="景点4">
<h2>景点4</h2>
<p>介绍景点4的相关信息。</p>
<div class="overlay">
<h3>景点4</h3>
<p>更加详细的介绍景点4。</p>
<a href="#">了解更多</a>
</div>
</div>
<div class="card fade-in">
<img src="https://picsum.photos/id/1004/400/300" alt="景点5">
<h2>景点5</h2>
<p>介绍景点5的相关信息。</p>
<div class="overlay">
<h3>景点5</h3>
<p>更加详细的介绍景点5。</p>
<a href="#">了解更多</a>
</div>
</div>
<div class="card fade-in slide-in-right">
<img src="https://picsum.photos/id/1005/400/300" alt="景点6">
<h2>景点6</h2>
<p>介绍景点6的相关信息。</p>
<div class="overlay">
<h3>景点6</h3>
<p>更加详细的介绍景点6。</p>
<a href="#">了解更多</a>
</div>
</div>
</div>
</body>
</html>
```
这个代码中,我们使用了 `flex` 布局来实现卡片的排列,每个卡片都带有自己的动画效果,当鼠标悬停在卡片上时,会弹出一个遮罩层,展示更多信息。你可以根据自己的需求,对代码进行修改和优化,让它更好地符合你的要求。
阅读全文
相关推荐
暗色系界面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/text.css" />
</head>
<body>
site map | FAQ's | help
Welcome
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam.
Learn more
About
Ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam.
Learn more
Latest News
JULY 18, 2010
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore. Learn more
Our Services Set ipsum dolor sit amet,
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy. Learn more Set ipsum dolor sit amet,
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy. Learn more Set ipsum dolor sit amet,
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy. Learn more Home | About | Services | Clients | Contacts Web design by 站长素材 Online <div </html>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore. Learn more
Our Services Set ipsum dolor sit amet,
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy. Learn more Set ipsum dolor sit amet,
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy. Learn more Set ipsum dolor sit amet,
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy. Learn more Home | About | Services | Clients | Contacts Web design by 站长素材 Online <div </html>