flex 布局 实现电商页面商品展示floor
有了上一篇,对flex的初次使用,心里痒痒的试着,实现了电商首页,商品展示的floor,先看下效果:

要实现首先是对组件构件的拆解,拆解如下:

页面布局如下:
<div class="floor">
<div class="floor-wrap">
<div class="floor-first">
<span class="floor-title">休闲零食</span>
<span>|</span>
<span class="floor-title-dec">精选美味 超值好货</span>
</div>
<div class="floor-second">
<div class="floor-second-left">
<img src="https://img-b2b.gznb.com/b2c/132202877794914304.jpg"/>
</div>
<div class="floor-second-right">
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div> </div>
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div>
</div>
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div>
</div>
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div>
</div>
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div>
</div>
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div>
</div>
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div>
</div>
<div class="product-show">
<div style="width: 200px;height: 200px">
<div class="product-show-pic"
style='background-image: url("https://img-b2b.gznb.com/b2c/133315103138254848.jpg")'></div>
</div>
<div class="product-show-desc">
<span class="title" style="font-size: 14px; color: rgb(74, 74, 74);">陕西省宝鸡市灵山薄壳核桃原味500g</span>
<span class="price" style="font-weight: 600;">¥23.8 </span>
</div>
<div class="cart-button">
<span>期待上线</span>
</div>
</div>
</div>
</div>
</div>
</div>
样式如下:
.floor {
display: flex;
width: 100%;
padding-bottom: 60px;
padding-top: 60px;
background-color: #f4f4f4;
flex-direction: column;
align-items: center;
justify-content: center;
}
.floor .floor-wrap {
/*指定宽度,两边留白*/
width: 1200px;
flex:;
margin: 10px;
}
.floor .floor-wrap .floor-first {
margin-bottom: 15px;
}
.floor .floor-wrap .floor-title {
margin-bottom: 30px;
letter-spacing: 0.5px;
font-size: 22px;
margin: 10px;
}
.floor .floor-wrap .floor-title-dec {
color: #333;
}
.floor .floor-wrap .floor-second-left {
width: 440px;
height: 520px;
}
.floor-second {
display: flex;
flex-direction: row;
}
.floor .floor-wrap .floor-second-right {
background: white;
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: wrap;
}
.product-show-desc {
padding: 10px;
}
.product-show-desc span {
overflow: hidden;
/*防止商品名称太长,多余的部分用...显示*/
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
white-space: nowrap;
width: 180px;
display: block;
}
.product-show-desc .price {
text-align: center;
color: red;
}
.floor .floor-wrap .floor-second-right .product-show {
width: 199px;
height: 259px;
border: 1px solid #f4f4f4;
/*商品展示的外边框,统一设置为1px solid,所以紧挨着两个的边框看起来是两像素,为了消灭一个边框,margin统一设置为-1px*/
margin-right: -1px;
margin-bottom: -1px;
margin-top: -1px;
}
.product-show-pic {
width: 80%;
height: 80%;
margin: 0px auto;
padding-top: 5%;
box-sizing: content-box;
background-size: contain;
background-repeat: no-repeat;
background-position: 50%;
}
.cart-button {
display: none;
width: 100%;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: white;
overflow: hidden;
position: relative;
top: -52px;
z-index:;
}
.cart-button span {
display: block;
flex-grow:;
background: red;
line-height: 52px;
height: 52px;
position: relative;
top: 52px;
/*本来是放置加入购物车按钮,鼠标悬浮才展示,默认是在外,被父元素overflow:hidden影藏*/
text-align: center;
/*展示动画*/
transition: .6s;
}
.product-show:hover .cart-button > span {
/*鼠标悬浮,激活动画,展示期待..*/
position: relative;
display: block;
top: 0px;
}
flex 弹性布局,在实现子元素对齐方式,和排列顺序上很方便!
flex 布局 实现电商页面商品展示floor的更多相关文章
- flex 布局 实现电商网页菜单的多级分类展示
用flex,实现多级菜单分类展示,这里记录一下,方便以后查阅. 效果展示如下: 跟上面floor的设计差不多,鼠标hover全部商品分类的时候,将下拉列表展示在指定区域,这个类似鼠标悬浮商品图片期待上 ...
- laravel 5.5 《电商实战 》基础布局
我们需要为我们的项目构建一个基础的页面布局,布局文件统一存放在 resources/views/layouts 文件夹中,布局涉及的文件如下: app.blade.php —— 主要布局文件,项目的所 ...
- iOS电商常见动画与布局、微信悬浮窗、音乐播放器、歌词解析、拖动视图等源码
iOS精选源码 MXScroll 介绍 混合使用UIScrollView ios 电商demo(实现各种常见动画效果和页面布局) 一行代码集成微信悬浮窗 可拖动,大小的视图,可放置在屏幕边缘. 在使用 ...
- Spark大型电商项目实战-及其改良之番外(1)-将spark前端页面效果高效拷贝至博客
Spark大型电商项目实战-及其改良这个系列的时间轴展示图一直在变....1-3篇是用图直接表示时间轴,用一段简陋的html代码表示时间表.第4篇开始才是用比较完整的前端效果,能移动.缩放时间轴,鼠标 ...
- Spring Boot 构建电商基础秒杀项目 (四) getotp 页面
SpringBoot构建电商基础秒杀项目 学习笔记 BaseController 添加 public static final String CONTENT_TYPE_FORMED = "a ...
- 利用 jQuery 操作页面元素的方法,实现电商网站购物车页面商品数量的增加和减少操作,要求单项价格和总价随着数量的改变而改变
查看本章节 查看作业目录 需求说明: 利用 jQuery 操作页面元素的方法,实现电商网站购物车页面商品数量的增加和减少操作,要求单项价格和总价随着数量的改变而改变 当用户单击"+" ...
- Flex布局做出自适应页面--语法和案例
本文发布在: github项目地址:https://github.com/tenadolanter/flex-layout-demo SegmentFault地址:https://segmentfau ...
- CSS3与页面布局学习总结——多种页面布局
一.负边距与浮动布局 1.1.负边距 所谓负边距就是margin取负值的情况,如margin:-40px:margin-left:-100%.当一个元素与另一个元素margin取负值时将拉近距离.常见 ...
- 电商项目app开发
购物app的开发 首先我们本次要写的是一个电商的项目,项目主要功能有登录.注册.商品展示.轮播图.加入购物车.购物车管理.支付管理.地址管理.个人信息的修改.商品的分类展示.微信支付等等.主要使用vu ...
随机推荐
- 字体图标库 IcoMoon IconFont Font Awesome的使用
在项目开发的过程中,我们会经常用到一些图标.但是我们在使用这些图标时,往往会遇到失真的情况,而且图片数量很多的话,页面加载就越慢.所以,我们可以使用字体图标的方式来显示图标,字体图标任意放大缩小不会失 ...
- k-近邻法(kNN)
原理: 已知一个训练样本集(有标签),计算待测试样本与所有训练样本的距离. 按距离从小到大进行排序并取前 k 个,统计 k 个中出现次数最多的分类为分类结果. 优点:精度高,对异常值不敏感,无数据输入 ...
- popstate事件在低版本webkit中的调用
popstate是H5的history系列中的事件,但是在低版本的webkit中会自动触发.H5中的history api是不会使页面发生跳转的,只是操作地址栏和响应的state属性而已,而且是手动操 ...
- 语音识别ASR - HTK(HResults)计算字错率WER、句错率SER
HResults计算字错率(WER).句错率(SER) 前言 好久没发文,看到仍有这么多关注的小伙伴,觉得不发篇文对不住.确实好久没有输出经验总结相关的文档,抽了个时间,整理了下笔记,发一篇关于ASR ...
- vue2.0自学笔记
前言: 一.优点: 轻量级.高效率.上手快.简单易学.文档全面而简洁 二.功能: 1.模板渲染 2.模块化 3.扩展功能:路由.Ajax 三.课程包含: 1.Vue实例 2.Vue组件 3.Vue指令 ...
- mybatis-spring和spring版本搭配问题
所报错误:org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer 匹配的版本(my ...
- with的上下文管理
1.with with语句是在Python2.6中出现的新语句.在Python2.6以前要正确的处理涉及到异常的资源管理时,需要使用try/finally代码结构.如要实现文件在操作出现异常时也能正确 ...
- JS变量的提升详解
此次说明的是var与function的变量提升 那么先看一段代码 <script type="text/javascript"> console.log(test); ...
- 文件属性和ls -lhi
第1章 无法上网及拍错过程 远程连接拍错过程 1. 查看路是否通畅 2. 是否有拦击 iptables(防火墙) selinux 3. 查看是否有条件 ...
- Struts中的匹配规则
<constant name="struts.action.extension" value="action,do,htm"/> 表示之后后缀名为a ...