纯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