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

东城建站推广wordpress做网盘资源

东城建站推广,wordpress做网盘资源,西安行业网站制作,北京模板网站开发需求 多个按钮根据弧度&#xff0c;延边均匀排列。 实现 HTML 分两级&#xff1b;第一级&#xff0c;外层定义按钮的 compose-container 宽度&#xff1b;第二级&#xff0c;按钮集合&#xff0c;使用方法 styleBtn(index)&#xff0c;根据索引计算&#xff1b; <div c…

需求

多个按钮根据弧度,延边均匀排列。

实现

HTML

  • 分两级;
  • 第一级,外层定义按钮的 compose-container 宽度;
  • 第二级,按钮集合,使用方法 styleBtn(index),根据索引计算;
<div class="compose-container flex-style-01"><div class="btn" v-for="(item, index) in btnNum" :key="index" :style="styleBtn(index)">{{ index }}</div>
</div>

CSS

  • compose-container:容器样式,使用 flex 布局,且设置 width
  • btn:按钮样式,无需设置 display
.compose-container {display: flex;width: 600px;height: 80px;margin: 50px 0;background: #409eff;.btn {width: 50px;height: 50px;line-height: 50px;background: #aec0d1;border-radius: 50%;text-align: center;vertical-align: middle;}
}

JavaScript

  • 如下方法是计算按钮 translateY 值;
  • 代码第 2 行,传参是按钮的索引值,从 0 开始;
  • 代码第 4 行,按钮的总个数;
  • 代码第 6 行,按钮垂直高度间隔,单位 px
  • 代码第 8 行,整体抬高,也可不设置;
  • 代码第 12 - 27 行,区分偶数和奇数,中心点计算;
  • 代码第 29 行,设置属性 translateY
// 按钮弧度高度
function styleBtn(index) {// 总个数const totalNum = 8;// 间隔高度,单位 pxconst gap = 8;// 整体抬高const raiseHeight = 28;let translateY = ''if(totalNum%2 === 0) { // 偶数const centerIdx = totalNum / 2;const n = centerIdx - index;// > 0 左侧,<= 右侧translateY = (n > 0) ? n * gap : (Math.abs(n)+1) * gap;}else { // 奇数const centerIdx = Math.floor(totalNum / 2);const n = centerIdx - index;if(centerIdx === index) {// 中心点translateY = gap;}else {translateY = (Math.abs(n)+1) * gap;}}return { transform: `translateY(${(translateY - raiseHeight)}px)` }
}

效果

偶数

  • 按钮个数为偶数,中间两个按钮在同一条水平线上;
  • 样式一,justify-content: center,根据按钮的 margin 属性设置间隔;
  • 样式二:justify-content: space-between,两端对齐,按钮之间的空间平均分配;
  • 样式三:justify-content: space-around,按钮两侧空间相等,但首尾按钮与容器边缘的空间是按钮之间空间的一半;
  • 样式四:justify-content: space-evenly,所有间距(包括首尾按钮与容器边缘的间距)都相等;

在这里插入图片描述

奇数

  • 按钮个数为奇数,中间一个按钮最高,其它左右两侧在同一条水平线上;
  • justify-content 设置同上;

在这里插入图片描述

完整代码

<template><div><h4>样式一:justify-content: center, 且设置btn margin </h4><div class="compose-container flex-style-01"><div class="btn" v-for="(item, index) in btnNum" :key="index" :style="styleBtn(index)">{{ index }}</div></div><h4>样式二:justify-content: space-between</h4><div class="compose-container flex-style-02"><div class="btn" v-for="(item, index) in btnNum" :key="index" :style="styleBtn(index)">{{ index }}</div></div><h4>样式三:justify-content: space-around</h4><div class="compose-container flex-style-03"><div class="btn" v-for="(item, index) in btnNum" :key="index" :style="styleBtn(index)">{{ index }}</div></div><h4>样式四:justify-content: space-evenly</h4><div class="compose-container flex-style-04"><div class="btn" v-for="(item, index) in btnNum" :key="index" :style="styleBtn(index)">{{ index }}</div></div></div>
</template><script setup>
import { ref } from 'vue';const btnNum = ref(7);// 按钮弧度高度
function styleBtn(index) {// 总个数const totalNum = btnNum.value;// 间隔高度,单位 pxconst gap = 8;// 整体抬高const raiseHeight = 28;let translateY = ''if(totalNum%2 === 0) { // 偶数const centerIdx = totalNum / 2;const n = centerIdx - index;// > 0 左侧,<= 右侧translateY = (n > 0) ? n * gap : (Math.abs(n)+1) * gap;}else { // 奇数const centerIdx = Math.floor(totalNum / 2);const n = centerIdx - index;if(centerIdx === index) {// 中心点translateY = gap;}else {translateY = (Math.abs(n)+1) * gap;}}return { transform: `translateY(${(translateY - raiseHeight)}px)` }
}
</script><style lang="scss" scoped>
.compose-container {display: flex;width: 600px;height: 80px;margin: 50px 0;background: #409eff;.btn {width: 50px;height: 50px;line-height: 50px;background: #aec0d1;border-radius: 50%;text-align: center;vertical-align: middle;}
}
.flex-style-01 {justify-content: center;.btn {margin: 0 6px;}
}
.flex-style-02 {justify-content: space-between;
}
.flex-style-03 {justify-content: space-around;
}
.flex-style-04 {justify-content: space-evenly;
}
</style>
http://www.yayakq.cn/news/639210/

相关文章:

  • 网站换主题开网店怎么找货源啊
  • 网站维护属于什么专业dede网站seo
  • 做网站设计公司赚钱吗邯郸市网络公司
  • 推广软件排行榜前十名优化网站排名公司
  • 麻涌仿做网站网站建设分为哪些方面
  • 做外贸用什么搜索网站四川和住房城乡建设厅网站
  • 免费网站seo软件wordpress地址 站点地址
  • 中国住建部网站官网做网站用什么语言
  • 哪里有未成年做的网站wordpress文章显示标题在首页
  • asp网站免费ui设计界面配色
  • 58同城一样的网站怎样建设昆山网站建设网站
  • 乐从网站开发jsp网站开发具体步骤
  • 食品网站建设策划自己做app软件开发
  • asp+sql server典型网站建设案例广东微信网站建设哪家专业
  • 凯里市住房和城乡建设局网站中国十大seo公司
  • 网站建设费用计入什么会计科目教育网站开发背景
  • 网站推广公司兴田德润官网多少四川成都旅游必去景点
  • 网站 not found绍兴企业自助建站
  • 一个网站值多少钱微信公众号定制
  • 购物网站seo搜索引擎优化方案龙江建站技术
  • 什么网站做专利检索报告抖音小程序入口在哪里
  • 南京明月建设集团网站网页图片居中怎么设置
  • 搜狗站长工具综合查询滁州市城市建设投资有限公司网站
  • 网站实名认证查询申请表青岛谷歌优化
  • 怎么做娱乐电玩网站工商注册号查询入口
  • 公司网站页面设计wordpress最新编辑器怎么还原
  • 未注册网站做各企业网站大概多少钱
  • 网站改版方案原则做像素画的网站
  • 什么网站程序好电脑网站转换成手机网站
  • 杭州企业营销网站建设公司国际俄罗斯乌克兰