仿淘宝搜索商品页面静态网页代码 - HTML & CSS
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>仿淘宝搜索商品页面</title>
<style>
/* CSS样式 */
body {
font-family: Arial, sans-serif;
margin: 0;
}
<pre><code> .container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.search-box {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.search-box input[type='text'] {
width: 500px;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.search-box button {
padding: 10px 20px;
font-size: 16px;
background-color: #f90;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
margin-left: 10px;
}
.search-results {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
}
.search-results .product {
border: 1px solid #ccc;
padding: 10px;
border-radius: 5px;
}
.search-results .product img {
max-width: 100%;
height: auto;
}
.search-results .product .title {
margin-top: 10px;
font-weight: bold;
}
.search-results .product .price {
margin-top: 5px;
color: #f90;
}
</style>
</code></pre>
</head>
<body>
<div class='container'>
<div class='search-box'>
<input type='text' placeholder='请输入商品名称'>
<button>搜索</button>
</div>
<div class='search-results'>
<div class='product'>
<img src='product1.jpg' alt='Product 1'>
<div class='title'>商品1</div>
<div class='price'>¥100</div>
</div>
<div class='product'>
<img src='product2.jpg' alt='Product 2'>
<div class='title'>商品2</div>
<div class='price'>¥200</div>
</div>
<div class='product'>
<img src='product3.jpg' alt='Product 3'>
<div class='title'>商品3</div>
<div class='price'>¥150</div>
</div>
<!-- 更多产品 -->
</div>
</div>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/hUwq 著作权归作者所有。请勿转载和采集!