css实现蛋糕品种选择点击切换效果代码
代码语言:html
所属分类:表单美化
代码描述:css实现蛋糕品种选择点击切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
:root {
--zoom:100;
--animation-speed:150;
--animation-state:running;
--float-duration:1.4s;
--tilt-duration:1.2s;
--slide-duration:.6s;
--slide-max-exposure:72%;
--mass:10.5rem;
--cake-initial-position:46%;
--cake-end-position:50%;
--cake-tilt:-2deg;
--cake-initial-shadow:.8;
--cake-end-shadow:1;
--cake-shadow-rotate:40deg;
--cake-shadow-offset:230rem;
--cake-shadow-blur:15rem
}
@-webkit-keyframes cake-shadow {
to {
transform:var(--shadow-transform) scale(var(--cake-end-shadow))
}
}@keyframes cake-shadow {
to {
transform:var(--shadow-transform) scale(var(--cake-end-shadow))
}
}@-webkit-keyframes cake-float {
to {
top:var(--cake-end-position)
}
}@keyframes cake-float {
to {
top:var(--cake-end-position)
}
}@-webkit-keyframes cake-tilt {
to {
transform:rotate(var(--cake-tilt))
}
}@keyframes cake-tilt {
to {
transform:rotate(var(--cake-tilt))
}
}:root {
--unit:1vmin;
--available-screen-min:665;
--px:calc(var(--zoom) *(var(--unit) / var(--available-screen-min)));
--clip-path-top:polygon(75% 21%,91.7% 59%,100% 100%,0 100%,55.3% 0);
--clip-path-side:polygon(0% .3%,100% 1.2%,93.7% 91%,5.6% 98.4%)
}
html,body {
height:100%;
margin:0;
overflow:hidden;
touch-action:none;
background-color:#fff
}
* {
font-size:calc(1 * var(--px))
}
label {
font-size:0!important
}
.slide,.slide div,.slide div::before,.slide div::after {
transform-style:preserve-3d;
background-repeat:no-repeat
}
label {
order:2
}
input {
order:1
}
input[type="radio"] {
border-width:0!important;
clip:rect(1px,1px,1px,1px)!important;
height:1px!important;
overflow:hidden!important;
padding:0!important;
position:absolute!important;
white-space:nowrap!important;
width:1px!important
}
#controls {
position:absolute;
font-size:0;
z-index:500;
left:50%;
bottom:max(6rem,90px);
transform:translateX(-50%);
width:100%;
display:flex;
place-content:center
}
#controls label {
--diameter:max(64rem,28px);
cursor:pointer;
position:relative;
width:var(--diameter);
height:var(--diameter);
box-sizing:border-box;
display:inline-block;
margin:0;
transform:scale(1);
transition:all cubic-bezier(0.68,-0.55,0.27,1.55) 200ms;
-webkit-tap-highlight-color:transparent
}
#controls label::before {
content:"";
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
border-radius:50%;
background-color:var(--p-color-1);
transform:scale(var(--s,0.8));
transition:inherit;
box-shadow:var(--sb,0 0 0 0 transparent),0 0 0 0 transparent
}
@media(orientation:landscape) {
#controls {
--landscape-factor:1;
left:30rem;
bottom:50%;
transform:translateY(50%);
width:auto;
height:100%;
flex-direction:column
}
}@media(orientation:portrait) {
#controls label {
margin-inline:3rem!important
}
}label:nth-of-type(1) {
--p-color-2:hsl(42,100%,91%);
--p-color-1:hsl(3,74%,28%)
}
label:nth-of-type(2) {
--p-color-1:hsl(24,100%,56%);
--p-color-2:hsl(29,88%,77%)
}
label:nth-of-type(3) {
--p-color-2:#ffe6a3;
--p-color-1:hsl(18,100%,71%)
}
label:nth-of-type(4) {
--p-color-1:hsl(18,62%,27%);
--p-color-2:hsl(19,62%,37%)
}
label:nth-of-type(5) {
--p-color-1:hsl(274,45%,40%);
--p-color-2:hsl(21,41%,87%)
}
label:nth-of-type(6) {
--p-color-1:hsl(157,24%,29%);
--p-color-2:hsl(42,84%,78%)
}
main,.slide {
position:absolute;
left:0;
top:0;
width:100%;
height:100%
}
.slide {
transition:all ease-out calc(var(--slide-duration) *(100 / var(--animation-speed)));
transition-delay:calc(var(--slide-duration) *(100 / var(--animation-speed)));
-webkit-clip-path:circle(0% at center);
clip-path:circle(0% at center)
}
.flavor:nth-of-type(1):checked ~ main>div:nth-of-type(1),.flavor:nth-of-type(2):checked ~ main>div:nth-of-type(2),.flavor:nth-of-type(3):checked ~ main>div:nth-of-type(3),.flavor:nth-of-type(4):checked ~ main>div:nth-of-type(4),.flavor:nth-of-type(5):checked ~ main>div:nth-of-type(5),.flavor:nth-of-type(6):checked ~ main>div:nth-of-type(6) {
transition-delay:0ms;
-webkit-clip-path:circle(var(--slide-max-exposure) at center);
clip-path:circle(var(--slide-max-exposure) at center);
z-index:100
}
.flavor:checked ~ #controls label {
opacity:.6
}
.flavor:nth-of-type(1):checked ~ #controls label:nth-of-type(1),.flavor:nth-of-type(2):checked ~ #controls label:nth-of-type(2),.flavor:nth-of-type(3):checked ~ #controls label:nth-of-type(3),.flavor:nth-of-type(4):checked ~ #controls label:nth-of-type(4),.flavor:nth-of-type(5):checked ~ #controls label:nth-of-type(5),.flavor:nth-of-type(6):checked ~ #controls label:nth-of-type(6) {
--s:1;
--sb:inset 0 0 0 max(2rem,2px) rgba(0,0,0,0.2);
opacity:1;
margin-block:calc(var(--landscape-factor,0) * 19rem)
}
.flavor:nth-of-type(1):focus-visible ~ #controls label:nth-of-type(1)::before,.flavor:nth-of-type(2):focus-visible ~ #controls label:nth-of-type(2)::before,.flavor:nth-of-type(3):focus-visible ~ #controls label:nth-of-type(3)::before,.flavor:nth-of-type(4):focus-visible ~ #controls label:nth-of-type(4)::before,.flavor:nth-of-type(5):focus-visible ~ #controls label:nth-of-type(5)::before,.flavor:nth-of-type(6):focus-visible ~ #controls label:nth-of-type(6)::before {
box-shadow:var(--sb),0 0 9rem 1rem var(--p-color-1)
}
.pastry,.shadow {
position:absolute;
left:50%
}
.slide-redvelvet {
background-color:#ffcdb2;
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0