Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Americano
Au lait
Capuccino
Corretto
Espresso
Latte
Lungo
Macchiato
Mocha
Ristretto
Choose your coffee
Coffee
Water
Liquor
Milk
Whipped cream
Milk foam
Steamed milk
Chocolate
css
:root { --main-bg-color: #d6b9a4; --cup-color: #474747; --cup-width: 30vw; --cup-height: 24vw; --cup-handle-width: 5vw; --cup-handle-height: calc(2 * var(--cup-handle-width)); --cup-border-width: 2vw; --cup-inside-width: calc(var(--cup-width) - var(--cup-border-width)); --cup-inside-height: calc(var(--cup-height) - var(--cup-border-width)); --border-width: 1vw; --main-border: var(--border-width) solid var(--cup-color); --plate-width: 25vw; --plate-height: 2vw; --coffee-bottom: 80%; --water-bottom: 0; --milk-bottom: 0; --liquor-bottom: 0; --whipped_cream-bottom: 0; --steamed_milk-bottom: 0; --milk_foam-bottom: 0; --chocolate-bottom: 0; --coffee-color: #3c302f; --water-color: #b1dce2; --milk-color: #f0ebe5; --liquor-color: #fc8626; --whipped_cream-color: #fceecb; --milk_foam-color: #fceecb; --steamed_milk-color: #ffd7b3; --chocolate-color: #391e09; } body { height: 100vh; width: 100vw; background: var(--main-bg-color); display: flex; justify-content: space-evenly; align-items: center; margin: auto; overflow: hidden; } a { position: absolute; top: 10px; left: 10px; } svg { height: 1.5rem; } .container { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 70vw; } .coffee_name { color: #f1faee; text-align: center; /* width: 100%; */ font-size: 4vw; } .options { display: grid; grid-gap: 1vh; grid-template-rows: repeat(10, 35px); grid-template-columns: 120px; justify-content: space-evenly; box-sizing: border-box; } .options button { user-select: none; background: rgba(214, 217, 227, 0.6); outline: none; font-size: 1rem; border: 2px solid #a67a60; box-shadow: none; color: #363636; box-sizing: border-box; border-radius: 1vh; } .options button:hover { cursor: pointer; border-width: 4px; background: rgba(255, 255, 255, 0.6); } .options .selected { border-width: 4px; background: rgba(255, 255, 255, 0.8); box-sizing: border-box; } .cup { width: var(--cup-width); height: var(--cup-height); border-radius: 0 0 10vw 10vw; position: relative; background-color: var(--cup-color); z-index: 10; box-sizing: border-box; } .cup::after { content: ""; position: absolute; top: 10%; left: calc(100% - 1vw); width: var(--cup-handle-width); height: var(--cup-handle-height); border: var(--main-border); border-radius: 50% 30%; } .plate { position: absolute; top: calc(100% + 1vw); left: calc((var(--cup-width) - var(--plate-width)) / 2); width: var(--plate-width); background: var(--cup-color); height: var(--plate-height); border-radius: 1vw; } .filling { position: absolute; left: calc(var(--cup-border-width) / 2); bottom: calc(var(--cup-border-width) / 2); width: var(--cup-inside-width); height: var(--cup-inside-height); overflow: hidden; border-radius: 0 0 10vw 10vw; background-color: var(--main-bg-color); bottom: 1vw; } .filling div { position: absolute; width: 100%; transition: all 1s linear; color: #817f75; display: flex; align-items: flex-start; justify-content: center; height: 0; overflow: hidden; font-size: 3vw; height: 100%; bottom: -100%; box-sizing: border-box; } .filling.reset.americano { --water-bottom: 0; --coffee-bottom: -60%; } .filling.reset.au_lait { --coffee-bottom: -50%; --milk-bottom: 0%; } .filling.reset.capuccino { --coffee-bottom: -65%; --steamed_milk-bottom: -35%; --milk_foam-bottom: 0; } .filling.reset.espresso { --coffee-bottom: -60%; } .filling.reset.latte { --coffee-bottom: -60%; --steamed_milk-bottom: -20%; --milk_foam-bottom: 0%; } .filling.reset.corretto { --coffee-bottom: -45%; --liquor-bottom: -25%; } .filling.reset.lungo { --water-bottom: 0; --coffee-bottom: -50%; } .filling.reset.macchiato { --coffee-bottom: -70%; --milk_foam-bottom: 0; } .filling.reset.mocha { --coffee-bottom: -60%; --chocolate-bottom: -40%; --steamed_milk-bottom: -20%; --whipped_cream-bottom: 0%; } .filling.reset.ristretto { --coffee-bottom: -80%; } div.chocolate { background: var(--chocolate-color); bottom: var(--chocolate-bottom); z-index: 6; } div.coffee { background: var(--coffee-color); bottom: var(--coffee-bottom); line-height: 4vw; z-index: 7; } div.liquor { background: var(--liquor-color); bottom: var(--liquor-bottom); z-index: 4; } div.milk { background: var(--milk-color); bottom: var(--milk-bottom); z-index: 2; } div.milk_foam { background: var(--milk_foam-color); bottom: var(--milk_foam-bottom); z-index: 5; } div.steamed_milk { background: var(--steamed_milk-color); bottom: var(--steamed_milk-bottom); z-index: 6; } div.water { background: var(--water-color); bottom: var(--water-bottom); } div.whipped_cream { background: var(--whipped_cream-color); bottom: var(--whipped_cream-bottom); z-index: 4; } .filling.reset { --coffee-bottom: -100%; --water-bottom: -100%; --milk-bottom: -100%; --liquor-bottom: -100%; --whipped_cream-bottom: -100%; --steamed_milk-bottom: -100%; --milk_foam-bottom: -100%; --chocolate-bottom: -100%; }
JavaScript
const coffee_name = document.querySelector(".coffee_name"); const coffee_filling = document.querySelector(".filling"); const buttons = document.querySelectorAll("button"); let current_element = null; const changeCoffeeType = (selected) => { if (current_element) { current_element.classList.remove("selected"); coffee_filling.classList.remove(current_element.id); } current_element = selected; coffee_filling.classList.add(current_element.id); current_element.classList.add("selected"); coffee_name.innerText = selected.innerText; }; const setActiveType = (element) => { element.toggleClass("selected"); }; [...buttons].forEach((button) => { button.addEventListener("click", () => { changeCoffeeType(button); }); });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>咖啡选择-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号