当前位置:首页 > 编程笔记 > 正文
已解决

Vue纯CSS实现掷色子

来自网友在路上 170870提问 提问时间:2023-11-04 03:23:16阅读次数: 70

最佳答案 问答题库708位专家为你答疑解惑

效果图:

在这里插入图片描述

在这里插入图片描述

实现代码

直接利用CSS3动画实现的效果,无js代码。

<template><div class="wrap"><input type="checkbox" id="roll"><label for="roll"><div class="content"></div></label></div></template><script>export default {name: "App",created() {},data(){return{}},methods: {}};</script><style lang="scss" scoped>.wrap {display: flex;width: 100vw;height: 100vh;margin:0;padding:0;justify-content: center;align-items: center;}.content {background: url(./dice.webp);background-position: 0% 100%;width: 366px;height: 366px;animation: roll .2s steps(5,start) infinite;position:relative;}@keyframes roll {/* from {background-position: 0% 100%;} */to {background-position: 100% 100%;}}#roll {display: none;}#roll:checked + label .content {animation-play-state: paused;}.content::before {content:'?';background:rgba(255,255,255,.8);width: inherit;height: inherit;display: flex;justify-content: center;align-items: center;font-size:320px;font-family: Helvetica;backdrop-filter: blur(20px);-webkit-backdrop-filter: blur(20px);border-radius: 60px;}#roll:checked +label .content::before{display: none;}</style>
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"Vue纯CSS实现掷色子":http://eshow365.cn/6-31463-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!