vue3+scss开启写轮眼

vue3+scss开启写轮眼

一、相关技术

采用vue3+vite+scss的技术内容进行开发

二、使用步骤

1.安装依赖

代码如下:

javascript 复制代码
npm install sass

2.眼球

首先我们根据需要 将眼睛的基础形状描绘出来,基础形状是由外眼线、内眼线以及中间的瞳孔组成

html 复制代码
<div class="outLine">
    <div class="innerLine">
        <div class="eyeBall"></div>
    </div>
</div>
css 复制代码
//外眼线
.outLine {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: red;
  border: 3px solid #000;
  display: flex;
  justify-content: center;
  align-items: center;
  //内眼线
  .innerLine {
    width: 50px;
    height: 50px;
    position: relative;
    border-radius: 50%;
    border: 3px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
	//瞳孔
    .eyeBall {
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: #000;
    }
  }
}

3 勾玉

要绘制一个勾玉,先对勾玉的形状进行分析,它是由一个圆和一个勾组成,因此我们可以使用css中的伪类来实现

定义一个div,类名为gouyu

typescript 复制代码
<template>
    <div class="gouyu"></div>
</template>

<style lang="scss" scoped>
//默认圆
.gouyu {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #000;
  position: absolute;
  top: 12px;
}
//添加勾
.gouyu:before {
  position: absolute;
  content: "";
  width: 12px;
  height: 10px;
  left: 2px;//左偏移量
  top: -6px;//上偏移量
  border: 0 solid transparent;//取消其余边框
  border-top: 6px solid #000000;//上边框
  border-radius: 20px 0 0 0;//上边框圆角
  transform: rotate(77deg);//勾旋转角度
}

4 旋转动画

要实现勾玉绕瞳孔旋转的效果,我们可以使用css3中的动画实现

css 复制代码
.gouyu {
  transform: rotate(0deg);//默认开始位置
  transform-origin: 50% 36px;//旋转中心,如不设置默认自旋转
  animation: 3s gouyuRotate-1850a03c linear infinite;//执行动画的时间,事件,无限次数
}
@keyframes gouyuRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(var(0deg));
  }
}

5 综合

结合二者即可实现以下效果,源代码在此

相关推荐
DiXinWang19 分钟前
关闭谷歌浏览器提示“若要接收后续 Google Chrome 更新,您需使用 Windows 10 或更高版本”的方法
前端·chrome
CoderYanger27 分钟前
前端基础——HTML练习项目:填写简历信息
前端·css·职场和发展·html
muyouking1132 分钟前
深入理解 HTML `<label>` 的 `for` 属性:提升表单可访问性与用户体验
前端·html·ux
软件技术NINI36 分钟前
html css js网页制作成品——饮料官网html+css+js 4页网页设计(4页)附源码
javascript·css·html
软件技术NINI36 分钟前
html css js网页制作成品——HTML+CSS辣条俱乐部网页设计(5页)附源码
javascript·css·html
IT_陈寒1 小时前
Java性能调优:从GC日志分析到实战优化的5个关键技巧,让你的应用快如闪电!
前端·人工智能·后端
Mintopia1 小时前
🚀 Next.js API 压力测试:一场前端与后端的“极限拉扯”
前端·后端·全栈
Mintopia1 小时前
🛡️ 对抗性攻击与防御:WebAI模型的安全加固技术
前端·javascript·aigc
庙堂龙吟奈我何1 小时前
qiankun知识点
前端
SoaringHeart2 小时前
Flutter封装:原生路由管理极简封装 AppNavigator
前端·flutter