有了上一篇,对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的更多相关文章

  1. flex 布局 实现电商网页菜单的多级分类展示

    用flex,实现多级菜单分类展示,这里记录一下,方便以后查阅. 效果展示如下: 跟上面floor的设计差不多,鼠标hover全部商品分类的时候,将下拉列表展示在指定区域,这个类似鼠标悬浮商品图片期待上 ...

  2. laravel 5.5 《电商实战 》基础布局

    我们需要为我们的项目构建一个基础的页面布局,布局文件统一存放在 resources/views/layouts 文件夹中,布局涉及的文件如下: app.blade.php —— 主要布局文件,项目的所 ...

  3. iOS电商常见动画与布局、微信悬浮窗、音乐播放器、歌词解析、拖动视图等源码

    iOS精选源码 MXScroll 介绍 混合使用UIScrollView ios 电商demo(实现各种常见动画效果和页面布局) 一行代码集成微信悬浮窗 可拖动,大小的视图,可放置在屏幕边缘. 在使用 ...

  4. Spark大型电商项目实战-及其改良之番外(1)-将spark前端页面效果高效拷贝至博客

    Spark大型电商项目实战-及其改良这个系列的时间轴展示图一直在变....1-3篇是用图直接表示时间轴,用一段简陋的html代码表示时间表.第4篇开始才是用比较完整的前端效果,能移动.缩放时间轴,鼠标 ...

  5. Spring Boot 构建电商基础秒杀项目 (四) getotp 页面

    SpringBoot构建电商基础秒杀项目 学习笔记 BaseController 添加 public static final String CONTENT_TYPE_FORMED = "a ...

  6. 利用 jQuery 操作页面元素的方法,实现电商网站购物车页面商品数量的增加和减少操作,要求单项价格和总价随着数量的改变而改变

    查看本章节 查看作业目录 需求说明: 利用 jQuery 操作页面元素的方法,实现电商网站购物车页面商品数量的增加和减少操作,要求单项价格和总价随着数量的改变而改变 当用户单击"+" ...

  7. Flex布局做出自适应页面--语法和案例

    本文发布在: github项目地址:https://github.com/tenadolanter/flex-layout-demo SegmentFault地址:https://segmentfau ...

  8. CSS3与页面布局学习总结——多种页面布局

    一.负边距与浮动布局 1.1.负边距 所谓负边距就是margin取负值的情况,如margin:-40px:margin-left:-100%.当一个元素与另一个元素margin取负值时将拉近距离.常见 ...

  9. 电商项目app开发

    购物app的开发 首先我们本次要写的是一个电商的项目,项目主要功能有登录.注册.商品展示.轮播图.加入购物车.购物车管理.支付管理.地址管理.个人信息的修改.商品的分类展示.微信支付等等.主要使用vu ...

随机推荐

  1. istio-mix介绍

    mixer 概念 Mixer 是负责提供策略控制和遥测收集的 Istio 组件: 在每次请求执行先决条件检查之前以及在每次报告遥测请求之后,Envoy sidecar 在逻辑上调用 Mixer. 主要 ...

  2. 2015-112 ado.net2

    CRUD:create read update delete 七. 数据绑定数据列的转换 在gridview中添加<OnRowDataBound="GridView1_RowDataB ...

  3. 2015-10-27 C#3

    三.字符串拼凑stringbuilder stringbuilder sb= new stringbuilder(); sb.append("aaa"); sb.append(&q ...

  4. js 取得当天0点 / 23:59:59 时间

    js 取得当天0点 / 23:59:59 时间   js 取得今天0点: const start = new Date(new Date(new Date().toLocaleDateString() ...

  5. c# Process cmd 执行完回调 Proc_OutputDataReceived mysql mysqldump mysql source备份还原数据

    c# Process 执行完回调 Proc_OutputDataReceived mysql mysqldump mysql source备份还原数据 直接贴代码 前提:mysql5.7 vs2017 ...

  6. JavaScript中的this详解

    前言 this用法说难不难,有时候函数调用时,往往会搞不清楚this指向谁?那么,关于this的用法,你知道多少呢? 下面我来给大家整理一下关于this的详细分析,希望对大家有所帮助! this指向的 ...

  7. 构建web应用之——maven创建以及SpringMVC配置

    构建web应用第一步需要创建以及配置maven项目管理,同时配置启动SpringMVC,这里推荐参考CSDN的一篇文章链接:https://blog.csdn.net/weixin_42222334/ ...

  8. learning makefile foreach

  9. FTP软件FileZilla 3.38.1下载

    FTP软件FileZilla 3.38.1下载 filezilla软件简介 FileZilla是一个免费开源的FTP软件,分为客户端版本和服务器版本,具备所有的FTP软件功能,具备极好的可控性及条理性 ...

  10. Triangle Count

    Given an array of integers, how many three numbers can be found in the array, so that we can build a ...