给我一个电商网站首页,只用html和css

时间: 2023-06-27 08:02:36 浏览: 72
好的,以下是一个简单的电商网站首页,仅使用HTML和CSS实现。 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>电商网站首页</title> <style> /* Reset styles */ * { margin: 0; padding: 0; box-sizing: border-box; } /* Header styles */ header { display: flex; justify-content: space-between; align-items: center; background-color: #f5f5f5; padding: 1rem; } header h1 { font-size: 2rem; font-weight: bold; color: #333; } header nav { display: flex; } header nav a { margin-left: 1rem; color: #333; text-decoration: none; font-weight: bold; } header nav a:hover { color: #666; } /* Main styles */ main { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 1rem; } .product { width: calc(33.33% - 1rem); margin-bottom: 1rem; border: 1px solid #ccc; padding: 1rem; text-align: center; } .product img { max-width: 100%; max-height: 150px; margin-bottom: 0.5rem; } .product h2 { font-size: 1.2rem; margin-bottom: 0.5rem; } .product p { font-size: 1rem; margin-bottom: 0.5rem; } .product button { background-color: #333; color: #fff; padding: 0.5rem; border: none; border-radius: 5px; cursor: pointer; } .product button:hover { background-color: #666; } /* Footer styles */ footer { background-color: #333; color: #fff; text-align: center; padding: 1rem; } footer p { margin-bottom: 0.5rem; } footer a { color: #fff; text-decoration: none; } footer a:hover { text-decoration: underline; } </style> </head> <body> <header> <h1>电商网站</h1> <nav> <a href="#">首页</a> <a href="#">商品</a> <a href="#">购物车</a> <a href="#">登录</a> </nav> </header> <main> <div class="product"> <img src="https://via.placeholder.com/150" alt="Product image" /> <h2>商品1</h2> <p>¥100.00</p> <button>加入购物车</button> </div> <div class="product"> <img src="https://via.placeholder.com/150" alt="Product image" /> <h2>商品2</h2> <p>¥200.00</p> <button>加入购物车</button> </div> <div class="product"> <img src="https://via.placeholder.com/150" alt="Product image" /> <h2>商品3</h2> <p>¥300.00</p> <button>加入购物车</button> </div> <div class="product"> <img src="https://via.placeholder.com/150" alt="Product image" /> <h2>商品4</h2> <p>¥400.00</p> <button>加入购物车</button> </div> <div class="product"> <img src="https://via.placeholder.com/150" alt="Product image" /> <h2>商品5</h2> <p>¥500.00</p> <button>加入购物车</button> </div> <div class="product"> <img src="https://via.placeholder.com/150" alt="Product image" /> <h2>商品6</h2> <p>¥600.00</p> <button>加入购物车</button> </div> </main> <footer> <p>版权所有 &copy; 2021 电商网站</p> <p>联系我们:<a href="mailto:info@ecommerce.com">info@ecommerce.com</a></p> </footer> </body> </html> ``` 这个网站首页包括一个顶部导航栏,一个主要内容区域以及一个底部版权声明。在主要内容区域中,使用了flex布局和calc()函数来实现一个简单的响应式布局。

相关推荐

最新推荐

recommend-type

基于html和CSS3制作酷炫的导航栏

CSS Code复制内容到剪贴板 &lt;!doctype html&gt;  html lang="en"&gt;  &lt;head&gt;  &lt;meta charset="UTF-8"&gt; &lt;!—-编码—–&gt;  &lt;meta name="Generator" content="EditPlus
recommend-type

html5+css3面试题答案.docx

html5+css3面试题答案.docx
recommend-type

纯js+html和纯css+html制作手风琴效果

本文分享了纯js+html制作手风琴和纯css+html制作手风琴两种效果,供大家参考,具体内容如下 一、纯css+html的手风琴效果 这种用css写的手风琴比较简单,主要是应用到css中的,transition属性。 代码如下: &lt;!...
recommend-type

css3实现一个div设置多张背景图片及background-image属性实例演示

主要介绍了css3实现一个div设置多张背景图片及background-image属性,同时对于css3背景渐变也做了详细的解释,水平渐变,左上角渐变等等方式,需要的朋友可以参考下
recommend-type

HTML+CSS实现单选框、复选框美观的样式

主要介绍了HTML+CSS实现单选框、复选框美观的样式,需要的朋友可以参考下
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

解释这行代码 c = ((double)rand() / RAND_MAX) * (a + b - fabs(a - b)) + fabs(a - b);

这行代码是用于生成 a 和 b 之间的随机数。首先,它使用 rand() 函数生成一个 [0,1) 之间的随机小数,然后将这个小数乘以 a、b 范围内的差值,再加上 a 和 b 中的较小值。这可以确保生成的随机数大于等于 a,小于等于 b,而且不会因为 a 和 b 之间的差距过大而导致难以生成足够多的随机数。最后,使用 fabs() 函数来确保计算结果是正数。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。