当前位置: 首页 > wzjs >正文

如何做实体店的网站网站推广网络推广

如何做实体店的网站,网站推广网络推广,阿里云服务器安装宝塔和wordpress,专门做赌博网站犯法吗瀑布流 1. 解释2. 形成结构和样式3. 自定义指令 1. 解释 瀑布流特征: 等宽不等高:元素宽度固定,高度根据内容自适应。错落排列:元素像瀑布一样从上到下依次填充,自动寻找最短列插入 体现:图中第一排1&…

瀑布流

    • 1. 解释
    • 2. 形成结构和样式
    • 3. 自定义指令

1. 解释

在这里插入图片描述

  • 瀑布流特征:
  1. 等宽不等高:元素宽度固定,高度根据内容自适应。
  2. 错落排列:元素像瀑布一样从上到下依次填充,自动寻找最短列插入

体现:图中第一排1,2,3元素中,3是最短高度,就是该行最短列。

2. 形成结构和样式

<template><div class="page-main"><div class="card"><!-- v-waterfall是自定义指令 属性值是个回调函数--><div v-waterfall="el => updateLayout(el)" class="card-item" v-for="item in cardDate" :key="item.id":style="{ background: item.color, height: item.height }"><p class="text">{{ item.id }}</p></div></div></div>
</template>
//这是<script>data中的数据,结构是通过v-for遍历的cardDate: [{ id: 1, color: '#76da6e', height: '100px' },{ id: 2, color: '#57c797', height: '80px' },{ id: 3, color: '#54cac7', height: '70px' },{ id: 4, color: '#b16dc7', height: '120px' },{ id: 5, color: '#dc933d', height: '130px' },{ id: 6, color: '#b74acf', height: '90px' },{ id: 7, color: '#d93e5a', height: '80px' },{ id: 8, color: '#5474dd', height: '100px' },{ id: 9, color: '#e42526', height: '120px' },{ id: 10, color: '#e86c92', height: '90px' }],
<style scoped>
/* .page-main {position: relative;
} */.card {position: relative;margin: 0 auto;width: calc(3 * 200px);/* 3列,每列200px宽度*/
}.card-item {/* 相对于最近的非static定位的祖先元素(.card)定位(0,0) */position: absolute;width: 200px;/* 使得内容居中(可省略) */display: flex;align-items: center;justify-content: center;color: black;font-size: 24px;/* 监听到css样式变化,过渡0.3s效果 */transition: all 0.3s;
}
</style>

未加上js动态计算每个元素的位置—初始样子是将所有元素重叠在一起(如图)
在这里插入图片描述
然后就要计算出每块元素应该存在的位置(top和left)【css中每块元素position都是absolute,而且没有设置边偏移,默认都是0】
在这里插入图片描述
DOM元素尺寸属性不了解可以看这里有图文说明

<script>
export default {name: 'App',data() {return {cardDate: [{ id: 1, color: '#76da6e', height: '100px' },{ id: 2, color: '#57c797', height: '80px' },{ id: 3, color: '#54cac7', height: '70px' },{ id: 4, color: '#b16dc7', height: '120px' },{ id: 5, color: '#dc933d', height: '130px' },{ id: 6, color: '#b74acf', height: '90px' },{ id: 7, color: '#d93e5a', height: '80px' },{ id: 8, color: '#5474dd', height: '100px' },{ id: 9, color: '#e42526', height: '120px' },{ id: 10, color: '#e86c92', height: '90px' }],columnHeights: [0, 0, 0] //每列元素的高度}},directives: {waterfall: {inserted(el, binding) {const callback = binding.value || {};callback(el);}}},methods: {updateLayout(item) {const column = this.getMinColumnHeight(this.columnHeights);//计算每个元素位移x轴和y轴距离const itemTop = this.columnHeights[column];const itemLeft = column * item.clientWidth;item.style.transform = `translate(${itemLeft}px,${itemTop}px)`;//此时该元素item已经定位完成//则重新跟新原本最短列为this.columnHeights[column] + item.offsetHeight; this.columnHeights[column] += item.offsetHeight;},getMinColumnHeight(arr) {let min = Math.min(...arr);return arr.indexOf(min) != -1 ? arr.indexOf(min) : 0;}},
}
</script>

3. 自定义指令

directives: {waterfall: {inserted(el, binding) {console.log(binding);const callback = binding.value || {};callback(el);}}},

在这里插入图片描述
el则是每个cart-item元素

(注:本文例子参考这个b站视频,我进行了补充)

http://www.dtcms.com/wzjs/32299.html

相关文章:

  • 专题页网站怎么做杭州seo排名费用
  • 公司建设网站费用做那个科目青岛seo网站排名优化
  • 达州建设网站电商中seo是什么意思
  • 南宁市网站建设哪家好如何在百度做免费推广产品
  • wordpress4.9.3漏洞搜索引擎排名优化
  • diy网站建设武汉seo公司
  • 从零开始做网站百度提交网址
  • 网站建设教程所需文字腾讯企点app
  • 买网站的域名网络营销工作内容是什么
  • 上海做网站公司排名优化营商环境个人心得体会
  • 长沙一键建站系统福州seo服务
  • 个人备案的域名可以做网站吗哪里有免费的网站推广
  • 电子商务网站建设的一般网络营销薪酬公司
  • 深圳营销型网站建设多少钱吉林黄页电话查询
  • 东莞营销型网站建设站长之家查询域名
  • 网站建设主机配置seo优化方案
  • 做网站需要解析吗南昌seo建站
  • 上海网站建设哪里好优化方案官方网站
  • dw做的网站怎么全屏站长工具seo综合
  • 郑州网站制作-中国互联内容营销是什么意思
  • 个人网站命名的要求企业培训课程推荐
  • 在云服务器上搭建网站什么时候友情链接
  • 优化网站公司价格是多少钱18岁以上站长统计
  • 互联网站建设机构网络营销方式有几种
  • 武汉市二手房交易合同备案在那个网站上做呀网络营销的市场背景
  • 江桥做网站百度快照关键词推广
  • 长沙精品网站制作博客网
  • 定制型网站建设多少钱济南网络优化哪家专业
  • 国外vps做网站测速经典软文范例大全
  • 建站平台 阿里巴巴一键搭建网站工具