纯css布局实现杯中蛋糕效果
代码语言:html
所属分类:布局界面
代码描述:纯css布局实现杯中蛋糕效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-size: 16px; } *:before, *:after { content: ""; position: absolute; } .container { height: 80vh; width: 80em; max-width: 80%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; } @media only screen and (max-width: 48em) { .container { flex-wrap: wrap; height: 100%; } } .dessert { position: relative; width: 25%; height: 50%; display: flex; flex-direction: column; align-items: center; } @media only screen and (max-width: 48em) { .dessert { width: 50%; } } .dessert::before { width: 8em; height: 1em; background: radial-gradient(ellipse at 45% 60%, #f0f1f4cc, transparent); border-radius: 50%; bottom: 0; } .dessert .cup { position: absolute; width: 7.8em; height: 3.75em; bottom: 0.5em; background: lightblue; clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%); border-radius: 2px 2px 40px 40px; z-index: 2; } .dessert.dessert-b .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), repeating-conic-gradient(at 50% 250%, rgba(255, 255, 255, 0.2) 0 1deg, rgba(255, 255, 255, 0.4) 0 2deg, rgba(255, 255, 255, 0) 0 3deg), linear-gradient(transparent 0.2rem, #40C6FF 0.2rem), radial-gradient(#40C6FF 50%, #73d5ff 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } @-moz-document url-prefix() { .dessert.dessert-b .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), linear-gradient(transparent 0.2rem, #40C6FF 0.2rem), radial-gradient(#40C6FF 50%, #73d5ff 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } } .dessert.dessert-g .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), repeating-conic-gradient(at 50% 250%, rgba(255, 255, 255, 0.2) 0 1deg, rgba(255, 255, 255, 0.4) 0 2deg, rgba(255, 255, 255, 0) 0 3deg), linear-gradient(transparent 0.2rem, #06BB9C 0.2rem), radial-gradient(#06BB9C 50%, #08ecc5 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } @-moz-document url-prefix() { .dessert.dessert-g .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), linear-gradient(transparent 0.2rem, #06BB9C 0.2rem), radial-gradient(#06BB9C 50%, #08ecc5 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } } .dessert.dessert-y .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), repeating-conic-gradient(at 50% 250%, rgba(255, 255, 255, 0.2) 0 1deg, rgba(255, 255, 255, 0.4) 0 2deg, rgba(255, 255, 255, 0) 0 3deg), linear-gradient(transparent 0.2rem, #FFCC6A 0.2rem), radial-gradient(#FFCC6A 50%, #ffdd9d 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } @-moz-document url-prefix() { .dessert.dessert-y .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), linear-gradient(transparent 0.2rem, #FFCC6A 0.2rem), radial-gradient(#FFCC6A 50%, #ffdd9d 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } } .dessert.dessert-r .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), repeating-conic-gradient(at 50% 250%, rgba(255, 255, 255, 0.2) 0 1deg, rgba(255, 255, 255, 0.4) 0 2deg, rgba(255, 255, 255, 0) 0 3deg), linear-gradient(transparent 0.2rem, #88011d 0.2rem), radial-gradient(#88011d 50%, #bb0128 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } @-moz-document url-prefix() { .dessert.dessert-r .cup { background: radial-gradient(ellipse at 0% 0%, transparent 60%, rgba(0, 0, 0, 0.1) 70%), linear-gradient(transparent 0.2rem, #88011d 0.2rem), radial-gradient(#88011d 50%, #bb0128 51% 74%, transparent 75%) 0 0/0.5rem 0.5rem; } } .dessert .cake { position: absolute; width: 8em; height: 2em; bottom: calc(0.5em + 3.75em - 0.8em); border-radius: 50%; background: linear-gradient(#805231 45%, #5b3a23 55%); } .dessert .cake.vanilla { background: linear-gradient(#E7AC4E 45%, #e19721 55%); } .icing { position: absolute; bottom: calc(3.75em + 1.2em); display: flex; flex-direction: column-reverse; align-items: center; } .icing.icing-strawberry .layer1, .icing.icing-strawberry .layer2, .icing.icing-strawberry .layer3 { background: linear-gradient(#FCE3E7 70%, #f28798 98%, #ca1633); box-shadow: inset -8px -8px rgba(202, 22, 51, 0.08); } .icing.icing-chocolate .layer1, .icing.icing-chocolate .layer2, .icing.icing-chocolate .layer3 { background: linear-gradient(#805231 70%, #362315 98%, black); box-shadow: inset -8px -8px rgba(0, 0, 0, 0.08); } .icing.icing-caramel .layer1, .icing.icing-caramel .layer2, .icing.icing-caramel .layer3 { background: linear-gradient(#ebc6a8 70%, #d89055 98%, #78451c); box-shadow: inset -8px -8px rgba(120, 69, 28, 0.08); } .icing.icing-cream .layer1, .icing.icing-cream .layer2, .icing.icing-cream .layer3 { background: linear-gradient(#E7E3D7 70%, #c1b697 98%, #776b48); box-shadow: inset -8px -8px rgba(119, 107, 72, 0.08); } .icing .layer1 { width: 7.6em; height: 1.2em; border-radius: 1rem; position: relative; } .icing .layer2 { width: 6.8em; height: 1.8em; border-radius: 1.2rem 1.2rem 0.5rem 0.5rem; position: relative; bottom: -0.2rem; } .icing .layer3 { width: 5.2em; height: 2em; border-radius: 150% 20% 30% 50%; position: relative; bottom: -0.8rem; } .icing .layer1::before, .icing .layer2::befor.........完整代码请登录后点击上方下载按钮下载查看
网友评论0