Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
{{ tempResult | number | hugeNumber }}
{{ calculation | number | calculation}}
AC
÷
×
+
-
7
8
9
4
5
6
1
2
3
.
0
=
css
body { height: 100vh; width: 100vw; background: #1939f6; overflow: hidden; } * { box-sizing: border-box; } #app { width: 100%; height: 100%; display: flex; font-family: "Roboto", sans-serif; font-weight: 300; font-size: 24px; } #app #calculator { opacity: 0; -webkit-animation: 1s bounceIn; animation: 1s bounceIn; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; margin: 10px; border-radius: 8px; color: #ffffff; box-shadow: 10px 10px 50px rgba(0, 0, 0, 0.5); margin: auto; height: 540px; width: 300px; background: #191b1d; } #app #calculator .screen-container { width: 100%; height: 38%; display: flex; flex-direction: column; position: relative; justify-content: center; text-align: right; } #app #calculator .screen-container .calculation, #app #calculator .screen-container .result { width: 100%; height: 50%; padding-right: 15px; } #app #calculator .screen-container .result { display: flex; align-items: flex-end; color: #1939f6; justify-content: flex-end; } #app #calculator .screen-container .result .number { font-size: 50px; font-weight: 800; } #app #calculator .btn-container { width: 100%; height: 62%; display: flex; flex-direction: column; position: relative; } #app #calculator .btn-container .oper-container { z-index: 10; opacity: 0; -webkit-animation: 1s bounceIn; animation: 1s bounceIn; -webkit-animation-delay: 0.5s; animation-delay: 0.5s; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; position: absolute; width: 50px; left: -25px; box-shadow: 10px 10px 50px rgba(0, 0, 0, 0.5); top: -100px; } #app #calculator .btn-container .oper-container .btn { position: static; width: 50px; height: 50px; background: #1939f6; color: #1939f6; background: #ffffff; display: flex; cursor: pointer; } #app #calculator .btn-container .oper-container .btn .number { margin: auto; } #app #calculator .btn-container .oper-container .btn#clear.animate { -webkit-animation: fade 0.12s ease-in-out; animation: fade 0.12s ease-in-out; animation-direction: reverse; } #app #calculator .btn-container .oper-container .btn#clear { cursor: pointer; height: 50px; width: 50px; display: flex; background: #1e2022; border-radius: 8px 0px 0 0; font-size: 16px; box-shadow: 10px 10px 50px rgba(0, 0, 0, 0.5); } #app #calculator .btn-container .oper-container .btn#clear .number { margin: auto; color: #ffffff; } #app #calculator .btn-container .row { position: relative; display: flex; flex-direction: row; width: 100%; height: 25%; } #app #calculator .btn-container .row .btn { cursor: pointer; width: 100%; height: 100%; text-align: center; display: flex; border: 0.5px solid #191b1d; background: #1e2022; } #app #calculator .btn-container .row .btn .number { opacity: 0; -webkit-animation: 1s fadeIn; animation: 1s fadeIn; -webkit-animation-delay: 0.5s; animation-delay: 0.5s; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; margin: auto; } #app #calculator .btn-container .row .btn:nth-child(1) { border-left: none; } #app #calculator .btn-container .row .btn:nth-child(3) { border-right: none; } #app #calculator .btn-container .row .btn.animate { -webkit-animation: fade 0.12s ease-in-out; animation: fade 0.12s ease-in-out; } #app #calculator .btn-container .row .btn#result { position: absolute; right: -12px; bottom: -12px; width: calc(33% * 1.25); height: calc(100% * 1.25); background: #1939f6; border-bottom-right-radius: 8px; border: 0.5px rgba(0, 0, 0, 0.0001); } #app #calculator .btn-container .row .btn#result:not(.resetappearanim) { opacity: 0; -webkit-animation: 1s bounceIn; animation: 1s bounceIn; -webkit-animation-delay: 0.5s; animation-delay: 0.5s; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; } #app #calculator .btn-container .row .btn#result.animate { -webkit-animation: fade 0.12s ease-in-out; animation: fade 0.12s ease-in-out; animation-direction: reverse; } #app #calculator .btn-container .row .btn#dot { border-bottom-left-radius: 8px; } #app #calculator .btn-container .row:last-child .btn { border-bottom: none; } #app #calculator .btn-container .btn.operations.animate { -webkit-animation: fadeThird 0.12s ease-in-out; animation: fadeThird 0.12s ease-in-out; animation-direction: reverse; } #app #calculator .btn-container .btn.operations.divide { left: calc(33% - 25px); top: calc(25% - 25px); } #app #calculator .btn-container .btn.operations.multiplication { left: calc(66% - 25px); top: calc(25% - 25px); } #app #calculator .btn-container .btn.operations.plus { left: calc(66% - 25px); top: calc(50% - 25px); } #app #calculator .btn-container .btn.operations.less { left: calc(33% - 25px); top: calc(50% - 25px); border-radius: 0 0 8px 0; } @-webkit-keyframes fade { from { background: #1e2022; } to { background: #1939f6; } } @keyframes fade { from { background: #1e2022; } to { background: #1939f6; } } @-webkit-keyframes fadeThird { from { background: #ffffff; } to { background: #1e2022; } } @keyframes fadeThird { from { background: #ffffff; } to { background: #1e2022; } } @-webkit-keyframes bounceIn { from, 20%, 40%, 60%, 80%, to { -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); } 0% { opacity: 0; transform: scale3d(0.3, 0.3, 0.3); } 20% { transform: scale3d(1.1, 1.1, 1.1); } 40% { transform: scale3d(0.9, 0.9, 0.9); } 60% { opacity: 1; transform: scale3d(1.03, 1.03, 1.03); } 80% { transform: scale3d(0.97, 0.97, 0.97); } to { opacity: 1; transform: scale3d(1, 1, 1); } } @keyframes bounceIn { from, 20%, 40%, 60%, 80%, to { -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); } 0% { opacity: 0; transform: scale3d(0.3, 0.3, 0.3); } 20% { transform: scale3d(1.1, 1.1, 1.1); } 40% { transform: scale3d(0.9, 0.9, 0.9); } 60% { opacity: 1; transform: scale3d(1.03, 1.03, 1.03); } 80% { transform: scale3d(0.97, 0.97, 0.97); } to { opacity: 1; transform: scale3d(1, 1, 1); } } @-webkit-keyframes bounce { from, 20%, 40%, 60%, 80%, to { -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); } 20% { transform: scale3d(1.1, 1.1, 1.1); } 40% { transform: scale3d(0.9, 0.9, 0.9); } 60% { transform: scale3d(1.03, 1.03, 1.03); } 80% { transform: scale3d(0.97, 0.97, 0.97); } to { opacity: 1; transform: scale3d(1, 1, 1); } } @keyframes bounce { from, 20%, 40%, 60%, 80%, to { -webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); } 20% { transform: scale3d(1.1, 1.1, 1.1); } 40% { transform: scale3d(0.9, 0.9, 0.9); } 60% { transform: scale3d(1.03, 1.03, 1.03); } 80% { transform: scale3d(0.97, 0.97, 0.97); } to { opacity: 1; transform: scale3d(1, 1, 1); } } @-webkit-keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .slide-fade-enter-active { transition: all 0.3s ease; } .slide-fade-enter, .slide-fade-leave-to { transform: translateX(10px); opacity: 0; } *:focus { outline: none; } @media screen and (max-width: 500px) { #app { transform: scale(0.8) translateY(-50px); } } *::-moz-selection { background: #1939f6; color: #ffffff; } *::selection { background: #1939f6; color: #ffffff; } [v-cloak] { display: none; }
JavaScript
String.prototype.replaceAll = function (search, replacement) { var target = this; return target.split(search).join(replacement); }; new Vue({ el: "#app", data: { // calculation:'15*98', // tempResult:'1470', calculation: "", tempResult: "" }, mounted() { let btns = document.querySelectorAll(".btn"); for (btn of btns) { btn.addEventListener("click", function () { this.classList.add("animate"); this.classList.add("resetappearanim"); }); btn.addEventListener("animationend", function () { this.classList.remove("animate"); }); } }, methods: { append(value) { this.calculation += value.toString(); }, clear() { this.calculation = ""; this.tempResult = ""; }, getResult() { if (this.tempResult != "") { this.calculation = this.tempResult; //this.tempResult = '' } }, backspace() { this.calculation = this.calculation.slice(0, -1); } }, watch: { calculation() { if ( this.calculation !== "" && !isNaN(this.calculation.slice(-1)) && this.calculation != this.result ) { this.tempResult = this.result.toString(); } } }, computed: { result() { if (!isNaN(this.calculation.slice(-1))) return eval(this.calculation); else return eval(this.calculation.slice(0, -1)); }, fontSize() { return (this.fontSize = 50 - this.tempResult.length * 1.25); } }, filters: { hugeNumber: (value) => { let parts = value.toString().split("."); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " "); return parts.join("."); }, number: (value) => { return value.replaceAll("*", "x"); }, calculation: (value) => { return value .replaceAll("x", " x ") .replaceAll("/", " / ") .replaceAll("+", " + ") .replaceAll("-", " - "); } } });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>vue.js - 计算器-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号