css制作京东
使用CSS制作京东风格页面
京东风格以红色为主色调,布局简洁明了,注重商品展示和用户体验。以下是一些关键CSS样式和布局技巧。
主色调与品牌风格 京东的品牌色为红色 (#e1251b),辅以白色和灰色。整体设计注重简洁和高效,减少视觉干扰。
:root {
--jd-red: #e1251b;
--jd-dark-red: #c9151e;
--jd-light-gray: #f5f5f5;
--jd-gray: #999;
--jd-dark-gray: #666;
}
导航栏设计 顶部导航栏通常包含logo、搜索框、用户导航等元素,固定在页面顶部。
.header {
height: 80px;
background-color: var(--jd-red);
display: flex;
align-items: center;
padding: 0 20px;
position: sticky;
top: 0;
z-index: 100;
}
.logo {
width: 190px;
height: 60px;
margin-right: 20px;
}
.search-bar {
flex: 1;
max-width: 600px;
height: 40px;
border-radius: 20px;
overflow: hidden;
background: white;
}
商品展示布局 商品卡片采用网格布局,包含图片、价格、评价等关键信息。
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 20px;
padding: 20px;
}
.product-card {
background: white;
border-radius: 4px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
transition: transform 0.3s;
}
.product-card:hover {
transform: translateY(-5px);
}
.product-image {
width: 100%;
height: 220px;
object-fit: cover;
}
.price {
color: var(--jd-red);
font-size: 18px;
font-weight: bold;
margin: 10px 0;
}
响应式设计 确保在不同设备上都能良好显示,使用媒体查询调整布局。
@media (max-width: 768px) {
.header {
height: 60px;
padding: 0 10px;
}
.product-grid {
grid-template-columns: repeat(2, 1fr);
gap: 10px;
padding: 10px;
}
.product-image {
height: 160px;
}
}
动画与交互效果 添加微交互提升用户体验,如悬停效果、加载动画等。
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.product-card {
animation: fadeIn 0.5s ease-out;
}
.add-to-cart {
background: var(--jd-red);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
transition: background 0.3s;
}
.add-to-cart:hover {
background: var(--jd-dark-red);
}
这些CSS技巧可以帮助构建一个类似京东风格的电商页面,注重品牌识别、用户体验和响应式设计。实际开发中还需要结合HTML结构和JavaScript交互功能。







