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 ...
随机推荐
- [leecode]---11.container with most water
description: Input: [1,8,6,2,5,4,8,3,7]Output: 49 思路1: 从(1,a1)开始向后算面积,需要两层n循环,时间复杂度n2 思路2: 找出数组中最大的数 ...
- windows+Apache+mod_wsgi+flask部署笔记
windows是用的2008 server 64位. 照着网上教程即可:https://www.jianshu.com/p/0aa1c7097976 但是有个问题: Apache2.4怎么配置???跟 ...
- C语言博客作业02——循环结构
1.本章学习总结 1.1思维导图 1.2本章学习体会及代码量学习体会 1.2.1学习体会 本周学习了循环结构,在之前学习分支结构的时候就涉及到了循环结构中的for循环,这周的又新学了while和do- ...
- JSON.stringify()方法是将一个javascript值(对象或者数组)转换成为一个JSON字符串;JSON.parse()解析JSON字符串,构造由字符串描述的javascript值或对象
JSON.stringify()方法是将一个javascript值(对象或者数组)转换成为一个JSON字符串:JSON.parse()解析JSON字符串,构造由字符串描述的javascript值或对象
- hive的排序,分組练习
hive的排序,分組练习 数据: 添加表和插入数据(数据在Linux本地中) create table if not exists tab1( IP string, SOURCE string, TY ...
- CentOS 7中关闭删除virbr0虚拟网卡
[问题] 虚拟机IP:192.168.31.101 本地物理机IP:192.168.31.254 虚拟机安装在本地物理机上 发现问题:本地物理机ping得通虚拟机IP,但是虚拟机无法ping通物理机I ...
- PHP:第一章——PHP中的变量002
预定义变量.变量的有效范围.可变变量.静态变量.php之外的变量 <?php /*****************************************************/ // ...
- 【技巧】easyUI的datagrid,如何在翻页以后仍能记录被选中的行
easyUI的datagrid在复选框多选时,如何在翻页以后仍能记录被选中的行: 注意datagrid中需要配置idField属性,一般为数据的主键
- 索引优化原则及Oracle中索引总结
索引建立原则 确定针对该表的操作是大量的查询操作还是大量的增删改操作. 尝试建立索引来帮助特定的查询.检查自己的sql语句,为那些频繁在where子句中出现的字段建立索引. where语句中不得不对查 ...
- implode() 数组元素组合函数
定义和用法 implode() 函数把数组元素组合为一个字符串. 语法:implode(separator,array); 说明 虽然 separator 参数是可选的.但是为了向后兼容,推荐您使用使 ...