uni-app 小宠物 - 会说话的小鸟

在 template 中

<view class="container"><view class="external-shape"><view class="face-box"><view class="eye-box eye-left"><view class="eyeball-box eyeball-left"><span class="pupil-box"><span class="pupil-reflex"></span></span></view></view><view class="eye-box eye-right"><view class="eyeball-box eyeball-right"><span class="pupil-box"><span class="pupil-reflex"></span></span></view></view><view class="nose-box"><view class="nostril-tip"></view><view class="nostril-tip"></view></view><view class="mouth-box"><view class="upper-teeth"></view><view class="lower-teeth"></view></view></view></view>
</view>

在 style 中

.container {$overall: #0097d9; // 整体背景// 眼睛部分$eyeBoxShadow: 8rpx 16rpx 10rpx rgba(0, 0, 0, 0.2); // 眼睛部分的阴影$eyeLeftBg: linear-gradient(to bottom, #fdfdfd, #c3efea); // 左眼背景$eyeRightBg: linear-gradient(to bottom, #fdfdfd, #e6d6f6); // 右眼背景// 眼球部分$eyeballLeftBg: linear-gradient(135deg, rgba(188, 248, 177, 0.7), #2fa38c 75%); // 左眼球背景$eyeballRightBg: linear-gradient(135deg, #f1a183, #8535cd); // 右眼球背景// 瞳孔部分$pupilBg: #2c2f32; // 瞳孔部分的背景$pupilBoxShadow: 0rpx 0rpx 20rpx rgba(0, 0, 0, 0.2); // 瞳孔部分的阴影$pupilReflexBg: #ebebeb; // 瞳孔反射部分的背景$pupilReflexBoxShadow: 20rpx 20rpx 20rpx rgba(255, 255, 255, 0.2); // 瞳孔反射部分的阴影// 鼻子部分$nostrilBg: rgba(0, 0, 0, 0.5); // 鼻孔的背景$nostrilBoxShadow: 8rpx 16rpx 10rpx rgba(0, 0, 0, 0.1); // 鼻孔的阴影// 嘴巴部分$mouthBg: #810332; // 嘴巴背景$mouthBorder: 50rpx solid #ffc333; // 嘴巴的边框$mouthBoxShadow: 8rpx 16rpx 10rpx rgba(0, 0, 0, 0.2); // 嘴巴的阴影$mouthBeforeBg: #400018; // 嘴巴内背景(在元素的内容前面插入新内容)[伪元素]$mouthAfterBg: #dc1b50; // 嘴巴内舌头(在元素的内容之后插入新内容)[伪元素]$upperBg: #fff; // 牙齿背景position: fixed;top: -70rpx;right: -150rpx;transform: scale(0.24);-o-transform: scale(0.24); // Opera-ms-transform: scale(0.24); // IE 9-moz-transform: scale(0.24); // Firefox-webkit-transform: scale(0.24); // Safari 和 Chromez-index: 9999;.external-shape {display: flex;justify-content: center;position: relative;width: 340rpx;height: 800rpx;border-top-left-radius: 400rpx;border-top-right-radius: 400rpx;background-color: $overall;box-shadow: 40rpx 40rpx 120rpx $overall;transform: rotate(-50deg);-o-transform: rotate(-50deg); // Opera-ms-transform: rotate(-50deg); // IE 9-moz-transform: rotate(-50deg); // Firefox-webkit-transform: rotate(-50deg); // Safari 和 Chrome}.face-box {display: flex;align-items: center;justify-content: center;flex-direction: column;position: absolute;top: 14%;width: 75%;height: 320rpx;}// 眼睛部分.eye-box {position: absolute;top: -10%;width: 130rpx;height: 130rpx;margin: 6rpx;background: #fff;transform: translateX(-50%);-o-transform: translateX(-50%); // Opera-ms-transform: translateX(-50%); // IE 9-moz-transform: translateX(-50%); // Firefox-webkit-transform: translateX(-50%); // Safari 和 Chromebox-shadow: $eyeBoxShadow;border-radius: 100%;// 眼球部分.eyeball-box {position: absolute;top: 25%;left: 50%;width: 55%;height: 55%;transform: translate(-50%);-o-transform: translate(-50%); // Opera-ms-transform: translate(-50%); // IE 9-moz-transform: translate(-50%); // Firefox-webkit-transform: translate(-50%); // Safari 和 Chromeborder-radius: 100%;z-index: 100;// 瞳孔部分.pupil-box {position: absolute;top: 25%;left: 50%;width: 55%;height: 55%;background: $pupilBg;transform: translate(-50%);-o-transform: translate(-50%); // Opera-ms-transform: translate(-50%); // IE 9-moz-transform: translate(-50%); // Firefox-webkit-transform: translate(-50%); // Safari 和 Chromebox-shadow: $pupilBoxShadow;border-radius: 100%;.pupil-reflex {position: absolute;top: 10%;left: 25%;width: 14rpx;height: 14rpx;background: $pupilReflexBg;transform: translate(-50%);-o-transform: translate(-50%); // Opera-ms-transform: translate(-50%); // IE 9-moz-transform: translate(-50%); // Firefox-webkit-transform: translate(-50%); // Safari 和 Chromebox-shadow: $pupilReflexBoxShadow;border-radius: 100%;}}}// 左眼球.eyeball-left {background: $eyeballLeftBg;}// 右眼球.eyeball-right {background: $eyeballRightBg;}}.eye-left {// 左眼left: 10%;background: $eyeLeftBg;}.eye-right {// 右眼left: 85%;background: $eyeRightBg;}// 鼻子部分.nose-box {top: 50%;display: flex;justify-content: space-between;width: 28%;height: auto;margin-bottom: 20rpx;.nostril-tip {width: 16rpx;height: 24rpx;background: $nostrilBg;box-shadow: $nostrilBoxShadow;border-radius: 40rpx;}}// 嘴巴部分.mouth-box {display: flex;align-items: center;justify-content: center;position: relative;width: 100%;height: 0%;overflow: hidden;background-color: $mouthBg;animation: mouth-animate 1.75s infinite;border: $mouthBorder;box-shadow: $mouthBoxShadow;box-sizing: border-box;border-radius: 200rpx;// 上牙齿.upper-teeth {position: absolute;top: -60rpx;width: 340rpx;height: 60rpx;background-color: $upperBg;animation: upper-teeth-animate 1.75s infinite;border-bottom-left-radius: 20rpx;border-bottom-right-radius: 20rpx;z-index: 100;}// 下牙齿.lower-teeth {position: absolute;bottom: 0;width: 200rpx;height: 60rpx;background-color: $upperBg;animation: lower-teeth-animate 1.75s infinite;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;z-index: 100;}}.mouth-box::before {content: "";position: absolute;width: 300rpx;height: 160rpx;background-color: $mouthBeforeBg;border-radius: 200rpx;}.mouth-box::after {content: "";position: absolute;bottom: -160rpx;width: 320rpx;height: 160rpx;background-color: $mouthAfterBg;border-top-left-radius: 50%;border-top-right-radius: 50%;animation: mouth-after-animate 1.75s infinite;}// 动画部分@keyframes upper-teeth-animate {0%,10%,80%,100% {top: -60rpx;}20% {top: 0rpx;}30% {top: -40rpx;}40% {top: -0rpx;}50% {top: -50rpx;}70% {top: 0rpx;}}@keyframes lower-teeth-animate {0%,10%,80%,100% {bottom: -60rpx;}20% {bottom: 0rpx;}30% {bottom: -40rpx;}40% {bottom: -0rpx;}50% {bottom: -50rpx;}70% {bottom: 0rpx;}}@keyframes mouth-animate {0%,10%,100% {width: 100%;height: 0%;}15% {width: 90%;height: 30%;}20% {width: 50%;height: 70%;}25% {width: 70%;height: 70%;}30% {width: 80%;height: 60%;}35% {width: 60%;height: 70%;}40% {width: 55%;height: 75%;}45% {width: 50%;height: 90%;}50% {width: 40%;height: 70%;}55% {width: 70%;height: 95%;}60% {width: 40%;height: 50%;}65% {width: 100%;height: 60%;}70% {width: 100%;height: 70%;}75% {width: 90%;height: 70%;}80% {width: 50%;height: 70%;}85% {width: 90%;height: 50%;}85% {width: 40%;height: 70%;}90% {width: 90%;height: 30%;}95% {width: 100%;height: 10%;}}@keyframes mouth-after-animate {0%,20%,100% {bottom: -160rpx;}30%,90% {bottom: -80rpx;}40% {bottom: -90rpx;}50% {bottom: -100rpx;}70% {bottom: -160rpx;}90% {bottom: -80rpx;}}
}

完整源码

<!-- 会说话的小鸟 -->
<template><view><view class="container"><view class="external-shape"><view class="face-box"><view class="eye-box eye-left"><view class="eyeball-box eyeball-left"><span class="pupil-box"><span class="pupil-reflex"></span></span></view></view><view class="eye-box eye-right"><view class="eyeball-box eyeball-right"><span class="pupil-box"><span class="pupil-reflex"></span></span></view></view><view class="nose-box"><view class="nostril-tip"></view><view class="nostril-tip"></view></view><view class="mouth-box"><view class="upper-teeth"></view><view class="lower-teeth"></view></view></view></view></view></view>
</template><script>
export default {data() {return {};},onLoad() {},methods: {}
};
</script><style lang="scss" scoped>
.container {$overall: #0097d9; // 整体背景// 眼睛部分$eyeBoxShadow: 8rpx 16rpx 10rpx rgba(0, 0, 0, 0.2); // 眼睛部分的阴影$eyeLeftBg: linear-gradient(to bottom, #fdfdfd, #c3efea); // 左眼背景$eyeRightBg: linear-gradient(to bottom, #fdfdfd, #e6d6f6); // 右眼背景// 眼球部分$eyeballLeftBg: linear-gradient(135deg, rgba(188, 248, 177, 0.7), #2fa38c 75%); // 左眼球背景$eyeballRightBg: linear-gradient(135deg, #f1a183, #8535cd); // 右眼球背景// 瞳孔部分$pupilBg: #2c2f32; // 瞳孔部分的背景$pupilBoxShadow: 0rpx 0rpx 20rpx rgba(0, 0, 0, 0.2); // 瞳孔部分的阴影$pupilReflexBg: #ebebeb; // 瞳孔反射部分的背景$pupilReflexBoxShadow: 20rpx 20rpx 20rpx rgba(255, 255, 255, 0.2); // 瞳孔反射部分的阴影// 鼻子部分$nostrilBg: rgba(0, 0, 0, 0.5); // 鼻孔的背景$nostrilBoxShadow: 8rpx 16rpx 10rpx rgba(0, 0, 0, 0.1); // 鼻孔的阴影// 嘴巴部分$mouthBg: #810332; // 嘴巴背景$mouthBorder: 50rpx solid #ffc333; // 嘴巴的边框$mouthBoxShadow: 8rpx 16rpx 10rpx rgba(0, 0, 0, 0.2); // 嘴巴的阴影$mouthBeforeBg: #400018; // 嘴巴内背景(在元素的内容前面插入新内容)[伪元素]$mouthAfterBg: #dc1b50; // 嘴巴内舌头(在元素的内容之后插入新内容)[伪元素]$upperBg: #fff; // 牙齿背景position: fixed;top: -70rpx;right: -150rpx;transform: scale(0.24);-o-transform: scale(0.24); // Opera-ms-transform: scale(0.24); // IE 9-moz-transform: scale(0.24); // Firefox-webkit-transform: scale(0.24); // Safari 和 Chromez-index: 9999;.external-shape {display: flex;justify-content: center;position: relative;width: 340rpx;height: 800rpx;border-top-left-radius: 400rpx;border-top-right-radius: 400rpx;background-color: $overall;box-shadow: 40rpx 40rpx 120rpx $overall;transform: rotate(-50deg);-o-transform: rotate(-50deg); // Opera-ms-transform: rotate(-50deg); // IE 9-moz-transform: rotate(-50deg); // Firefox-webkit-transform: rotate(-50deg); // Safari 和 Chrome}.face-box {display: flex;align-items: center;justify-content: center;flex-direction: column;position: absolute;top: 14%;width: 75%;height: 320rpx;}// 眼睛部分.eye-box {position: absolute;top: -10%;width: 130rpx;height: 130rpx;margin: 6rpx;background: #fff;transform: translateX(-50%);-o-transform: translateX(-50%); // Opera-ms-transform: translateX(-50%); // IE 9-moz-transform: translateX(-50%); // Firefox-webkit-transform: translateX(-50%); // Safari 和 Chromebox-shadow: $eyeBoxShadow;border-radius: 100%;// 眼球部分.eyeball-box {position: absolute;top: 25%;left: 50%;width: 55%;height: 55%;transform: translate(-50%);-o-transform: translate(-50%); // Opera-ms-transform: translate(-50%); // IE 9-moz-transform: translate(-50%); // Firefox-webkit-transform: translate(-50%); // Safari 和 Chromeborder-radius: 100%;z-index: 100;// 瞳孔部分.pupil-box {position: absolute;top: 25%;left: 50%;width: 55%;height: 55%;background: $pupilBg;transform: translate(-50%);-o-transform: translate(-50%); // Opera-ms-transform: translate(-50%); // IE 9-moz-transform: translate(-50%); // Firefox-webkit-transform: translate(-50%); // Safari 和 Chromebox-shadow: $pupilBoxShadow;border-radius: 100%;.pupil-reflex {position: absolute;top: 10%;left: 25%;width: 14rpx;height: 14rpx;background: $pupilReflexBg;transform: translate(-50%);-o-transform: translate(-50%); // Opera-ms-transform: translate(-50%); // IE 9-moz-transform: translate(-50%); // Firefox-webkit-transform: translate(-50%); // Safari 和 Chromebox-shadow: $pupilReflexBoxShadow;border-radius: 100%;}}}// 左眼球.eyeball-left {background: $eyeballLeftBg;}// 右眼球.eyeball-right {background: $eyeballRightBg;}}.eye-left {// 左眼left: 10%;background: $eyeLeftBg;}.eye-right {// 右眼left: 85%;background: $eyeRightBg;}// 鼻子部分.nose-box {top: 50%;display: flex;justify-content: space-between;width: 28%;height: auto;margin-bottom: 20rpx;.nostril-tip {width: 16rpx;height: 24rpx;background: $nostrilBg;box-shadow: $nostrilBoxShadow;border-radius: 40rpx;}}// 嘴巴部分.mouth-box {display: flex;align-items: center;justify-content: center;position: relative;width: 100%;height: 0%;overflow: hidden;background-color: $mouthBg;animation: mouth-animate 1.75s infinite;border: $mouthBorder;box-shadow: $mouthBoxShadow;box-sizing: border-box;border-radius: 200rpx;// 上牙齿.upper-teeth {position: absolute;top: -60rpx;width: 340rpx;height: 60rpx;background-color: $upperBg;animation: upper-teeth-animate 1.75s infinite;border-bottom-left-radius: 20rpx;border-bottom-right-radius: 20rpx;z-index: 100;}// 下牙齿.lower-teeth {position: absolute;bottom: 0;width: 200rpx;height: 60rpx;background-color: $upperBg;animation: lower-teeth-animate 1.75s infinite;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;z-index: 100;}}.mouth-box::before {content: "";position: absolute;width: 300rpx;height: 160rpx;background-color: $mouthBeforeBg;border-radius: 200rpx;}.mouth-box::after {content: "";position: absolute;bottom: -160rpx;width: 320rpx;height: 160rpx;background-color: $mouthAfterBg;border-top-left-radius: 50%;border-top-right-radius: 50%;animation: mouth-after-animate 1.75s infinite;}// 动画部分@keyframes upper-teeth-animate {0%,10%,80%,100% {top: -60rpx;}20% {top: 0rpx;}30% {top: -40rpx;}40% {top: -0rpx;}50% {top: -50rpx;}70% {top: 0rpx;}}@keyframes lower-teeth-animate {0%,10%,80%,100% {bottom: -60rpx;}20% {bottom: 0rpx;}30% {bottom: -40rpx;}40% {bottom: -0rpx;}50% {bottom: -50rpx;}70% {bottom: 0rpx;}}@keyframes mouth-animate {0%,10%,100% {width: 100%;height: 0%;}15% {width: 90%;height: 30%;}20% {width: 50%;height: 70%;}25% {width: 70%;height: 70%;}30% {width: 80%;height: 60%;}35% {width: 60%;height: 70%;}40% {width: 55%;height: 75%;}45% {width: 50%;height: 90%;}50% {width: 40%;height: 70%;}55% {width: 70%;height: 95%;}60% {width: 40%;height: 50%;}65% {width: 100%;height: 60%;}70% {width: 100%;height: 70%;}75% {width: 90%;height: 70%;}80% {width: 50%;height: 70%;}85% {width: 90%;height: 50%;}85% {width: 40%;height: 70%;}90% {width: 90%;height: 30%;}95% {width: 100%;height: 10%;}}@keyframes mouth-after-animate {0%,20%,100% {bottom: -160rpx;}30%,90% {bottom: -80rpx;}40% {bottom: -90rpx;}50% {bottom: -100rpx;}70% {bottom: -160rpx;}90% {bottom: -80rpx;}}
}
</style>

参考:【会说话的小鸟】给你的微信小程序加一个宠物吧

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/145666.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

腾讯云创建了jenkins容器,但无法访问

1、首先&#xff0c;查看本机能不能ping通你的腾讯云服务器 如果ping的通那就下一步 2、查看腾讯云服务器的防火墙关了没&#xff0c;没关关掉、 firewall-cmd --state not running 3、那就在云服务器的控制台开放端口

手写SVG图片

有时候QT中可能会需要一些简单的SVG图片,但是网上的质量参差不齐,想要满意的SVG图片,我们可以尝试直接手写的方法. 新建文本文档,将以下代码复制进去,修改后缀名为.svg,保存 <?xml version"1.0" encoding"utf-8"?> <svg xmlns"http://www…

C#冒泡排序算法

冒泡排序实现原理 冒泡排序是一种简单的排序算法&#xff0c;其原理如下&#xff1a; 从待排序的数组的第一个元素开始&#xff0c;依次比较相邻的两个元素。 如果前面的元素大于后面的元素&#xff08;升序排序&#xff09;&#xff0c;则交换这两个元素的位置&#xff0c;使…

关于AES加密输出密文不为128位的倍数的原因

今天尝试用AES-256-OFB加密一个flag结果输出的密文是43字节&#xff0c;不是128位&#xff08;16字节&#xff09;的倍数&#xff0c;代码如下&#xff1a; import os from Crypto.Cipher import AES databflag{a7ba7128-3917-4551-8260-b3499e9dd7b12} aes AES.new(os.urand…

如何进行高效的代码审查

代码审查是软件开发过程中至关重要的一环。它是指由开发团队中的其他成员对代码进行检查&#xff0c;以确保代码的质量和一致性。 代码审查可以帮助发现潜在的问题&#xff0c;例如内存泄漏、安全漏洞或性能问题。通过及早发现这些问题&#xff0c;可以避免它们在后期的软件开…

初识测开/测试

前言 在进入软件测试的正式讲解之前&#xff0c;我们需要对这个行业有一个整体的了解。 当我们从软件开发转向软件测试的时候&#xff0c;多数公司是欢迎的&#xff0c;而且难度也小。 反之&#xff0c;当我们从软件测试转向软件开发的时候&#xff0c;难度将会变得很大。 关于…

驱动作业10.23

现象 test.c #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include "head.h"in…

微信小程序一键获取位置

需求 有个表单需要一键获取对应位置 并显示出来效果如下&#xff1a; 点击一键获取获取对应位置 显示在 picker 默认选中 前端 代码如下: <view class"box_7 {{ showChange1? change-style: }}"><view class"box_11"><view class"…

物联网_00_物理网介绍

1.物联网为什么会出现? 一句话-----追求更高品质的生活, 随着科技大爆炸, 人类当然会越来越追求衣来伸手饭来张口的懒惰高品质生活, 最早的物联网设备可以追溯到19世纪末的"在线可乐售卖机"和"特洛伊咖啡壶"(懒惰的技术人员为了能够实时看到物品的情况而设…

SSM - Springboot - MyBatis-Plus 全栈体系(三十五)

第八章 项目实战 四、后台功能开发 2. 首页模块开发 2.1 查询首页分类 2.1.1 需求描述 进入新闻首页,查询所有分类并动态展示新闻类别栏位 2.1.2 接口描述 url 地址&#xff1a;portal/findAllTypes 请求方式&#xff1a;get 请求参数&#xff1a;无 响应数据&#xff…

漏洞复现--金和OASQL注入

免责声明&#xff1a; 文章中涉及的漏洞均已修复&#xff0c;敏感信息均已做打码处理&#xff0c;文章仅做经验分享用途&#xff0c;切勿当真&#xff0c;未授权的攻击属于非法行为&#xff01;文章中敏感信息均已做多层打马处理。传播、利用本文章所提供的信息而造成的任何直…

前端构建但没有更新

使用jenkins构建vue前端代码时&#xff0c;构建完成后&#xff0c;jenkins提示构建成功&#xff0c; 但前端刷新提示还是原来的效果&#xff0c;此时需要查看下jenkins构建日志&#xff0c;如果出现下面的文字&#xff0c;说明缺少依赖&#xff0c;最新的代码并没有构建到项目中…