用html+css洗一个小米商城头部
时间: 2023-05-26 18:01:31 浏览: 128
可以的,以下是一个简单的示例代码:
HTML:
```
<header class="header">
<div class="logo">
<a href="#"><img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/84b567c7ba5b5d5c7a2f847746af9ef9.png" alt="小米商城"></a>
</div>
<nav class="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>
<li><a href="#">路由器</a></li>
</ul>
</nav>
<div class="search">
<form>
<input type="text" placeholder="搜索商品">
<button type="submit"><i class="icon-search"></i></button>
</form>
</div>
</header>
```
CSS:
```
.header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.logo img {
max-width: 120px;
}
.nav ul {
display: flex;
margin: 0;
padding: 0;
list-style: none;
}
.nav li {
margin-left: 30px;
}
.nav a {
display: block;
color: #333;
font-size: 18px;
text-decoration: none;
}
.search {
position: relative;
}
.search input {
width: 300px;
height: 35px;
padding: 5px 10px;
border: none;
border-radius: 5px;
font-size: 16px;
}
.search button {
position: absolute;
top: 5px;
right: 10px;
width: 25px;
height: 25px;
border: none;
background-color: transparent;
}
.search button i {
display: block;
width: 25px;
height: 25px;
background-image: url('https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/1014a2bad283491516d4b99a4a695034.png');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
```
可以根据自己的需要进行调整,比如颜色、字体、布局等。
阅读全文