用html编写一个页面,要求有轮播图,二级菜单
时间: 2024-05-22 22:15:27 浏览: 69
<!DOCTYPE html>
<html>
<head>
<title>我的页面</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">关于我们</a></li>
<li class="dropdown">
<a href="#">产品</a>
<div class="dropdown-content">
<a href="#">产品1</a>
<a href="#">产品2</a>
<a href="#">产品3</a>
</div>
</li>
<li><a href="#">联系我们</a></li>
</ul>
</nav>
</header>
<section id="slider">
<div class="slide-container">
<div class="slide">
<img src="https://picsum.photos/800/400" alt="slide 1">
</div>
<div class="slide">
<img src="https://picsum.photos/800/400" alt="slide 2">
</div>
<div class="slide">
<img src="https://picsum.photos/800/400" alt="slide 3">
</div>
</div>
</section>
<main>
<h1>欢迎来到我的页面</h1>
<p>这是一个使用HTML编写的页面,包括轮播图和二级菜单。</p>
</main>
<footer>
<p>版权 © 2021 我的页面</p>
</footer>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
/* CSS */
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
header {
background-color: #333;
color: #fff;
padding: 10px;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
justify-content: space-between;
}
nav ul li a {
color: #fff;
text-decoration: none;
padding: 10px;
}
.dropdown {
position: relative;
}
.dropdown-content {
position: absolute;
top: 100%;
left: 0;
background-color: #f9f9f9;
min-width: 160px;
z-index: 1;
display: none;
}
.dropdown:hover .dropdown-content {
display: block;
}
#slider {
height: 400px;
background-color: #ccc;
position: relative;
}
.slide-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.slide {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
opacity: 0;
transition: opacity 1s ease-in-out;
}
.slide.active {
opacity: 1;
}
.slide img {
width: 100%;
height: 100%;
object-fit: cover;
}
main {
padding: 20px;
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
阅读全文