趁着周末无聊,做点事情!用div+css制作一个简易的产品推荐排行榜单。效果如上图,需要更多排列的自己在代码中添加即可。品牌信息可以自己去修改,每一项都设置有链接,插入网址即可跳转到指定页面。下面上代码:
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>产品推荐排行榜</title> <style> .ranking-list { width: 100%; max-width: 800px; margin: 20px auto; font-family: 'Microsoft YaHei', Arial, sans-serif; } .ranking-item { position: relative; display: block; margin-bottom: 10px; padding: 15px 20px; background: #fff; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); text-decoration: none; color: #333; transition: all 0.3s ease; } .ranking-item:hover { transform: translateX(10px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); } .rank-number { display: inline-block; width: 40px; height: 40px; line-height: 40px; text-align: center; border-radius: 6px; font-weight: bold; margin-right: 20px; } .ranking-item:nth-child(1) .rank-number { background: #ffd700; color: #c10b0b; } .ranking-item:nth-child(2) .rank-number { background: #c0c0c0; color: #2c3e50; } .ranking-item:nth-child(3) .rank-number { background: #cd7f32; color: #34495e; } .ranking-item:nth-child(n+4) .rank-number { background: #f0f0f0; color: #666; } .brand-info { display: inline-block; vertical-align: middle; } .brand-name { font-size: 18px; font-weight: 600; margin-bottom: 5px; } .brand-desc { font-size: 14px; color: #666; max-width: 600px; } /* 响应式设计 */ @media (max-width: 768px) { .ranking-item { padding: 12px 15px; } .brand-name { font-size: 16px; } .brand-desc { font-size: 13px; } } </style> </head> <body> <div class="ranking-list"> <a href="#link1" class="ranking-item"> <span class="rank-number">1</span> <div class="brand-info"> <div class="brand-name">品牌名称A</div> <div class="brand-desc">品牌亮点描述文字,这里展示产品的主要卖点和特色说明</div> </div> </a> <a href="#link2" class="ranking-item"> <span class="rank-number">2</span> <div class="brand-info"> <div class="brand-name">品牌名称B</div> <div class="brand-desc">品牌亮点描述文字,这里展示产品的主要卖点和特色说明</div> </div> </a> <a href="#link3" class="ranking-item"> <span class="rank-number">3</span> <div class="brand-info"> <div class="brand-name">品牌名称C</div> <div class="brand-desc">品牌亮点描述文字,这里展示产品的主要卖点和特色说明</div> </div> </a> <!-- 第4-10名重复结构,此处省略部分示例 --> <a href="#link4" class="ranking-item"> <span class="rank-number">4</span> <div class="brand-info"> <div class="brand-name">品牌名称D</div> <div class="brand-desc">品牌亮点描述文字...</div> </div> </a> </div> </body> </html>
继续阅读
评论