你可以用html和css写一下电脑段小米商城主页的代码吗
时间: 2024-01-26 22:03:59 浏览: 140
小米商城html+css页面
好的,以下是一个简单的HTML和CSS代码示例,可以作为您构建小米商城电脑版主页的起点:
HTML代码:
```
<!DOCTYPE html>
<html>
<head>
<title>小米商城-电脑版</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<nav>
<a href="#" class="logo">
<img src="https://i1.mifile.cn/a4/staticIndex/logo.png" alt="小米商城">
</a>
<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>
<li><a href="#">智能硬件</a></li>
<li><a href="#">服务</a></li>
</ul>
<form action="#" method="get">
<input type="text" name="search" placeholder="搜索">
<button type="submit">搜索</button>
</form>
<a href="#" class="cart">
<i class="iconfont icon-cart"></i>
<span>购物车</span>
<span class="cart-num">0</span>
</a>
</nav>
</header>
<main>
<section class="banner">
<img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/5d91af573e5e0d3e8b7a2ed3b45f2f7d.jpg" alt="小米商城-电脑版banner">
</section>
<section class="product-list">
<h2>小米手机</h2>
<ul>
<li>
<a href="#">
<img src="https://i1.mifile.cn/a4/xmad_16025713034864_jjvqD.jpg" alt="小米10">
<p>小米10</p>
<p>3299元起</p>
</a>
</li>
<li>
<a href="#">
<img src="https://i1.mifile.cn/a4/xmad_15918493854264_RsVhK.jpg" alt="Redmi K30 Pro">
<p>Redmi K30 Pro</p>
<p>2299元起</p>
</a>
</li>
<li>
<a href="#">
<img src="https://i1.mifile.cn/a4/xmad_16002534341448_DlrZy.jpg" alt="Redmi 9">
<p>Redmi 9</p>
<p>799元起</p>
</a>
</li>
<li>
<a href="#">
<img src="https://i1.mifile.cn/a4/xmad_15952726184116_pUFlw.jpg" alt="小米CC9 Pro">
<p>小米CC9 Pro</p>
<p>1999元起</p>
</a>
</li>
</ul>
<a href="#" class="more">更多</a>
</section>
</main>
<footer>
<div class="container">
<div class="footer-links">
<a href="#">联系我们</a>
<a href="#">关于小米</a>
<a href="#">加入小米</a>
<a href="#">投资者关系</a>
<a href="#">企业社会责任</a>
<a href="#">法律声明</a>
<a href="#">友情链接</a>
</div>
<div class="footer-info">
<p>© 2021 小米商城</p>
</div>
</div>
</footer>
</body>
</html>
```
CSS代码:
```
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #fff;
padding: 10px 20px;
box-shadow: 0 3px 6px rgba(0,0,0,0.1);
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 10;
}
nav {
display: flex;
align-items: center;
justify-content: space-between;
}
.logo img {
height: 40px;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav li {
margin: 0 10px;
}
nav li a {
color: #333;
text-decoration: none;
font-size: 14px;
}
nav form input[type="text"] {
padding: 5px 10px;
border: none;
border-radius: 2px;
}
nav form button[type="submit"] {
padding: 5px 10px;
background-color: #f60;
color: #fff;
border: none;
border-radius: 2px;
cursor: pointer;
}
.cart {
display: flex;
align-items: center;
color: #333;
font-size: 14px;
text-decoration: none;
margin-left: 20px;
position: relative;
}
.cart-num {
background-color: #f60;
color: #fff;
font-size: 12px;
padding: 2px 5px;
border-radius: 50%;
position: absolute;
top: -8px;
right: -8px;
}
.icon-cart {
font-size: 18px;
margin-right: 5px;
}
.main {
margin-top: 80px;
}
.banner img {
width: 100%;
height: auto;
}
.product-list {
margin-top: 50px;
}
.product-list h2 {
font-size: 24px;
margin-bottom: 20px;
}
.product-list ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
}
.product-list li {
margin: 0 20px 40px 20px;
text-align: center;
}
.product-list li a {
display: block;
text-decoration: none;
color: #333;
}
.product-list li img {
width: 200px;
height: auto;
margin-bottom: 10px;
}
.product-list li p {
margin: 10px 0;
}
.more {
display: block;
margin-top: 20px;
text-align: center;
color: #f60;
font-size: 16px;
font-weight: bold;
text-decoration: none;
}
.footer {
background-color: #f5f5f5;
padding: 20px 0;
}
.footer .container {
max-width: 1200px;
margin: 0 auto;
}
.footer-links {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.footer-links a {
color: #666;
font-size: 14px;
margin: 0 10px;
text-decoration: none;
}
.footer-info {
text-align: center;
margin-top: 20px;
font-size: 14px;
}
```
这只是一个简单的示例,您可以根据自己的需要添加更多内容和样式。
阅读全文