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>

相关推荐
集成显卡39 分钟前
PlayWright | 初识微软出品的 WEB 应用自动化测试框架
前端·chrome·测试工具·microsoft·自动化·edge浏览器
前端小趴菜051 小时前
React - 组件通信
前端·react.js·前端框架
Amy_cx2 小时前
在表单输入框按回车页面刷新的问题
前端·elementui
dancing9992 小时前
cocos3.X的oops框架oops-plugin-excel-to-json改进兼容多表单导出功能
前端·javascript·typescript·游戏程序
后海 0_o2 小时前
2025前端微服务 - 无界 的实战应用
前端·微服务·架构
Scabbards_2 小时前
CPT304-2425-S2-Software Engineering II
前端
小满zs3 小时前
Zustand 第二章(状态处理)
前端·react.js
程序猿小D3 小时前
第16节 Node.js 文件系统
linux·服务器·前端·node.js·编辑器·vim
萌萌哒草头将军3 小时前
🚀🚀🚀Prisma 发布无 Rust 引擎预览版,安装和使用更轻量;支持任何 ORM 连接引擎;支持自动备份...
前端·javascript·vue.js
鱼馅饼3 小时前
vscode使用系列之快速生成html模板
ide·vscode·html