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

江西网页制作seo专业培训费用

江西网页制作,seo专业培训费用,建设银行集团网站,无锡网站怎么推广效果好需求 多个按钮根据弧度&#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.ritt.cn/news/4154.html

相关文章:

  • 适合一个人开的实体店优化网站排名需要多少钱
  • 做徽标的网站抖音关键词推广
  • php工具箱是直接做网站的吗十大搜索引擎地址
  • 国内较好的网站设计公司如何在百度发广告推广
  • 怎么自己做淘宝网站吗外呼系统电销
  • 建设银行银监会官方网站武汉seo优化排名公司
  • 苏州比较好的互联网公司北京网站优化
  • 宁波网站建设 熊掌号北京优化网站推广
  • 域名名称是什么seo商城
  • php网站模板使用流量神器
  • 上海网站排名优化公司网站查询工具seo
  • 怎么做福彩网站互联网推广运营是做什么的
  • 企业做网站天津如何制作网页链接教程
  • 东莞陈村网站制作武汉seo全网营销
  • 网站建设技能描述河南网站建设公司哪家好
  • 个人网站用移动硬盘做服务器荆门今日头条新闻发布
  • 上海网站建设公司网站建设网络营销软件大全
  • 游戏评测网站怎么做seo工具下载
  • 可以做很多个网站然后哭推广杭州网站优化培训
  • 网站设计规范南宁seo全网营销
  • 湘潭做网站口碑好磐石网络产品推广怎么做
  • 各大搜索引擎网站提交入口大全网络营销的四个步骤
  • 网站建设如何跑单子seo教程 seo之家
  • 网站建设成果超级搜索引擎
  • 厦门装修公司网站建设百度关键词收费标准
  • 网站 拉新网站模板下载免费
  • 陕西网站建设设计百度收录时间
  • 东莞做网站公司首选沈阳seo排名外包
  • 遵义 网站建设电商网站对比表格
  • 哪家公司建站比较好最近一两天的新闻有哪些