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 ...
随机推荐
- requests库/爬取zhihu表情包
先学了requests库的一些基本操作,简单的爬了一下. 用到了requests.get()方法,就是以GET方式请求网页,得到一个Response对象.不加headers的话可能会400error所 ...
- dp背包问题
0-1背包 1.问题定义: 给定n种物品和背包.物品i的重量是wi,价值是vi,每种物品只有一个,背包容量为C.问:应该如何选择装入背包的物品,使得装入背包中的物品总值最大. 2.算法思路: 选择装入 ...
- 2015-10-27 C#3
三.字符串拼凑stringbuilder stringbuilder sb= new stringbuilder(); sb.append("aaa"); sb.append(&q ...
- C语言按位运算符
C语言按位运算符 二进制反码或按位取反:~ 一元运算符~是逐位将1变为0,0变为1 Eg: ~(1001 1010) Result:(0110 0101) 按位与:& 二元运算符&是 ...
- 用EPPlus 读取excel,代码出错, the given key is not present in the dictionary
using (ExcelPackage ep = new ExcelPackage(new FileInfo(path))) { ExcelWorksheet ws = ep.Workbook.Wor ...
- jsp页面怎么引入js
人老了,容易忘记事情,再此记录 这里需要注意的是js文件夹要直接放在WebRoot或者WebContent文件夹下面,不要放在WEB-INF下面.因为TomCat对WEB-INF这个文件夹下面的资源是 ...
- Django的url控制器
一 url配置 Django 1.11版本 URLConf官方文档 URL配置(URLconf)就像Django 所支撑网站的目录.它的本质是URL与要为该URL调用的视图函数之间的映射表.也就是ur ...
- vs code编写的时候自动回车的原因
今天在书写一个空白的scss文件的时候,刚打2个字就自动回车换行了: 测试了几次,发现了规律就是输入停下来0.5秒左右就会自动换行,比如,打了2个中文,再连续打一个句子,键盘虽然在动,但是vs cod ...
- Python中类的__init__继承
Python中类的__init__继承 概念: 定义父类 In [10]: class Person: ....: def __init__(self,name,age,sex): ....: sel ...
- HDU1237
/************************************************************** 作者:陈新 邮箱:cx2pirate@gmail.com 用途:hdu1 ...