html+css+js淘宝商品界面

点击商品,alert弹出商品ID

图片使用了占位符图片,加载可能会慢一点 你可以把它换成自己的图片😃源代码在图片后面

效果图

源代码

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>淘宝购物界面</title>
<style>
body {
font-family: Arial, sans-serif;
}
.header {
background-color: red;
color: white;
padding: 10px;
text-align: center;
border-radius: 5px 5px 0 0;
}
.container {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 20px;
}
.product {
width: 30%;
margin: 10px;
border: 1px solid #ddd;
border-radius: 5px;
overflow: hidden;
position: relative;
cursor: pointer;
}
.product img {
width: 100%;
height: auto;
}
.product-info {
padding: 10px;
}
.product-id {
display: none;
}
</style>
<script>
function showProductId(productId) {
alert("商品ID: " + productId);
}
</script>
</head>
<body>
<div class="header">淘宝</div>
<div class="container">
<div class="product" οnclick="showProductId('001')">
<img src="https://via.placeholder.com/150" alt="商品图片">
<div class="product-info">
<p>示例商品1</p>
<span class="product-id">001</span>
</div>
</div>
<div class="product" οnclick="showProductId('002')">
<img src="https://via.placeholder.com/150" alt="商品图片">
<div class="product-info">
<p>示例商品2</p>
<span class="product-id">002</span>
</div>
</div>
<div class="product" οnclick="showProductId('003')">
<img src="https://via.placeholder.com/150" alt="商品图片">
<div class="product-info">
<p>示例商品3</p>
<span class="product-id">003</span>
</div>
</div>
<div class="product" οnclick="showProductId('004')">
<img src="https://via.placeholder.com/150" alt="商品图片">
<div class="product-info">
<p>示例商品4</p>
<span class="product-id">004</span>
</div>
</div>
<div class="product" οnclick="showProductId('005')">
<img src="https://via.placeholder.com/150" alt="商品图片">
<div class="product-info">
<p>示例商品5</p>
<span class="product-id">005</span>
</div>
</div>
<div class="product" οnclick="showProductId('006')">
<img src="https://via.placeholder.com/150" alt="商品图片">
<div class="product-info">
<p>示例商品6</p>
<span class="product-id">0026</span>
</div>
</div>
<!-- 更多商品... -->
</div>
</body>
</html>

相关推荐
wenzhangli71 小时前
Ooder A2UI 核心架构深度解析:WEB 拦截层的设计与实现
前端·架构
前端百草阁2 小时前
【前端性能优化全链路指南】从开发编写到构建运行的多维度实践
前端·性能优化
神探小白牙2 小时前
eCharts 多系列柱状图增加背景图
javascript·ecmascript·echarts
女生也可以敲代码2 小时前
AI时代下的50道前端开发面试题:从基础到大模型应用
前端·面试
ZhengEnCi2 小时前
M5-markconv自定义CSS样式指南 📝
前端·css·python
IT_陈寒2 小时前
SpringBoot自动配置的坑差点让我加班到天亮
前端·人工智能·后端
xingpanvip2 小时前
星盘接口开发文档:星相日历接口指南
android·开发语言·前端·css·php·lua
@PHARAOH3 小时前
WHAT - GitLens supercharged 插件
前端
TT模板3 小时前
苹果cms整合西瓜播放器XGplayer插件支持跳过片头尾
前端·html5
Wect4 小时前
React 性能优化精讲
前端·react.js·性能优化