模仿淘宝写一个e乐购首页的网页代码
时间: 2024-01-20 21:04:01 浏览: 202
很抱歉,我作为AI语言模型无法直接提供完整的代码,但我可以为您提供一份e乐购首页的HTML和CSS代码示例,供您参考:
HTML代码示例:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>e乐购首页</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div class="logo">
<a href="#"><img src="logo.png" alt="e乐购"></a>
</div>
<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>
<li><a href="#">商城</a></li>
</ul>
</nav>
<div class="search">
<form action="#" method="get">
<input type="text" name="keyword" placeholder="请输入关键词">
<button type="submit">搜索</button>
</form>
</div>
<div class="cart">
<a href="#"><img src="cart.png" alt="购物车"><span>0</span></a>
</div>
</header>
<main>
<section class="banner">
<img src="banner.jpg" alt="e乐购">
</section>
<section class="hot-sale">
<h2>热卖商品</h2>
<ul>
<li>
<a href="#">
<img src="product1.jpg" alt="商品1">
<p>商品1</p>
<span>¥99.00</span>
</a>
</li>
<li>
<a href="#">
<img src="product2.jpg" alt="商品2">
<p>商品2</p>
<span>¥199.00</span>
</a>
</li>
<li>
<a href="#">
<img src="product3.jpg" alt="商品3">
<p>商品3</p>
<span>¥299.00</span>
</a>
</li>
<li>
<a href="#">
<img src="product4.jpg" alt="商品4">
<p>商品4</p>
<span>¥399.00</span>
</a>
</li>
</ul>
</section>
<section class="new-arrival">
<h2>新品上市</h2>
<ul>
<li>
<a href="#">
<img src="product5.jpg" alt="商品5">
<p>商品5</p>
<span>¥199.00</span>
</a>
</li>
<li>
<a href="#">
<img src="product6.jpg" alt="商品6">
<p>商品6</p>
<span>¥299.00</span>
</a>
</li>
<li>
<a href="#">
<img src="product7.jpg" alt="商品7">
<p>商品7</p>
<span>¥399.00</span>
</a>
</li>
<li>
<a href="#">
<img src="product8.jpg" alt="商品8">
<p>商品8</p>
<span>¥499.00</span>
</a>
</li>
</ul>
</section>
</main>
<footer>
<p>©2021 e乐购</p>
</footer>
</body>
</html>
```
CSS代码示例:
```
* {
margin: 0;
padding: 0;
}
header {
height: 80px;
background-color: #fff;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
}
.logo img {
height: 50px;
}
nav ul {
display: flex;
}
nav li {
margin: 0 10px;
}
nav a {
color: #333;
text-decoration: none;
font-size: 16px;
}
nav a:hover {
color: #c00;
}
.search form {
display: flex;
align-items: center;
}
.search input[type="text"] {
height: 30px;
width: 200px;
padding: 0 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.search button[type="submit"] {
height: 30px;
background-color: #c00;
color: #fff;
border: none;
border-radius: 5px;
padding: 0 10px;
margin-left: 10px;
cursor: pointer;
}
.cart a {
position: relative;
display: flex;
align-items: center;
color: #333;
text-decoration: none;
font-size: 16px;
}
.cart img {
height: 30px;
margin-right: 10px;
}
.cart span {
position: absolute;
top: -5px;
right: -5px;
background-color: #c00;
color: #fff;
border-radius: 50%;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
}
main {
max-width: 1200px;
margin: 0 auto;
}
.banner img {
width: 100%;
}
.hot-sale h2, .new-arrival h2 {
font-size: 24px;
font-weight: bold;
margin: 20px 0;
}
.hot-sale ul, .new-arrival ul {
display: flex;
flex-wrap: wrap;
}
.hot-sale li, .new-arrival li {
width: 25%;
padding: 10px;
box-sizing: border-box;
}
.hot-sale a, .new-arrival a {
display: flex;
flex-direction: column;
align-items: center;
text-decoration: none;
color: #333;
font-size: 16px;
}
.hot-sale img, .new-arrival img {
height: 200px;
margin-bottom: 10px;
}
.hot-sale p, .new-arrival p {
margin-bottom: 5px;
}
.hot-sale span, .new-arrival span {
color: #c00;
font-size: 18px;
font-weight: bold;
}
```
请根据您的具体需求和设计风格进行相应的修改和调整。
阅读全文