css布局实现啤酒瓶饮料饮品容器杯子效果代码

代码语言:html

所属分类:布局界面

代码描述:css布局实现啤酒瓶饮料饮品容器杯子效果代码

代码标签: css 啤酒 饮料 饮品 容器 杯子

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<style>
    html {
  --beer: #674d06;
  --beer-glass: #e29121;
  --beer-foam: #f9e1b6;
  --beer-bubble: #e29121;
  --beer-glass-detail: #e2c165;
  --cocktail1: #ee3636;
  --cocktail2: #c61414;
  --cocktail3: #b50505;
  --cocktail-glass: #ffd4bf;
  --straw: #ffffff;
  --straw-stripe: #0d5ec6;
  --whisky-glass: #a1c1c1;
  --whisky: #b56a06;
  --ice: #9ef6ff;
}

body {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  background-color: black;
  min-height: 100vh;
}

#beer,
#cocktail,
#whisky {
  width: 200px;
  height: 200px;
  position: relative;
}

/*BEER*/
#glass {
  width: 50%;
  height: 60%;
  position: absolute;
  bottom: 0%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--beer);
  border-radius: 0.2em 0.2em 2em 2em;
  border-style: solid;
  border-color: var(--beer-glass);
  border-width: 0.6em 0.5em 1.1em 0.5em;
}
#glass .foam.drip {
  -webkit-animation-name: beerDrip;
          animation-name: beerDrip;
  -webkit-animation-fill-mode: forwards;
          animation-fill-mode: forwards;
}
#glass .foam.drip:nth-child(1) {
  top: -0.8em;
  left: -1em;
  width: 0.7em;
  height: 0em;
  border-radius: 0.6em;
  -webkit-animation-duration: 10s;
          animation-duration: 10s;
}
#glass .foam.drip:nth-child(2) {
  top: 0.4em;
  left: 0.5em;
  width: 1.2em;
  height: 0em;
  border-radius: 0.6em;
  -webkit-animation-duration: 7s;
          animation-duration: 7s;
}
#glass .foam {
  background-color: var(--beer-foam);
  position: absolute;
  border-radius: 50%;
  z-index: 1;
}
#glass .foam:nth-child(1) {
  top: -1.8em;
  left: -1em;
  width: 3em;
  height: 3em;
}
#glass .foam:nth-child(2) {
  top: -2em;
  left: 1.4em;
  width: 3.7em;
  height: 3.7em;
}
#glass .foam:nth-child(3) {
  top: -1.8em;
  left: 4.4em;
  width: 3em;
  height: 3em;
}
#glass .foam:nth-child(3):after {
  content: "";
  display: block;
}
#glass .foam:nth-child(4) {
  top: -2.7em;
  width: 3em;
  height: 3em;
}
#glass .bubble {
  position: absolute;
  border-radius: 50%;
  background-color: var(--beer-bubble);
  -webkit-animation-name: beerBubble;
          animation-name: beerBubble;
  -webkit-animation-timing-function: linear;
          animation-timing-function: linear;
  -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
  opacity: 0;
  transform: translateY(0em);
  top: 6.6em;
}
#glass .bubble:nth-child(1) {
  -webkit-animation-duration: 1s;
          animation-duration: 1s;
  left: 4em;
  width: 0.4em;
  height: 0.4em;
}
#glass .bubble:nth-child(2) {
  -webkit-animation-duration: 1.2s;
          animation-duration: 1.2s;
  left: 2em;
  width: 0.5em;
  height: 0.5em;
}
#glass .bubble:nth-child(3) {
  -webkit-animation-duration: 1.4s;
          animation-duration: 1.4s;
  left: 3.2em;
  width: 0.5em;
  height: 0.5em;
}
#glass .bubble:nth-child(4) {
  -webkit-animation-duration: 0.8s;
          animation-duration: 0.8s;
  left: 5.1em;
  width: 0.3em;
  height: 0.3em;
}
#glass:after {
  content: "";
  display: block;
  width: 1.4em;
  height: 4em;
  background-color: transparent;
  border: 0.7em solid #e29121;
  border-radius: 0 1.3em 1.3em 0;
  position: absolute;
  top: 12%;
  left: 100%;
}

#details .glassEffect {
  position: absolute;
  background-color: var(--beer-glass-detail);
}
#details .glassEffect:nth-child(1) {
  width: 0.4em;
  height: 1.1em;
  top: 5.9em;
  left: 8.4em;
  border-radius: 0.6em;
}
#details .glassEffect:nth-child(2) {
  width: 0.4em;
  height: 3.2em;
  top: 7.4em;
  left: 8.4em;
  border-radius: 0.6em;
}

@-webkit-keyframes beerDrip {
  0% {
    height: 0em;
  }
  100% {
    height: 5em;
  }
}

@keyframes beerDrip {
  0% {
    height: 0em;
  }
  100% {
    height: 5em;
  }
}
@-webkit-keyframes beerBubble {
  0% {
    transform: translateY(0em);
    opacity: 0;
  }
  100% {
    transform: translateY(-6.5em);
    opacity: 1;
  }
}
@keyframes beerBubble {
  0% {
    transform: translateY(0em);
    opacity: 0;
  }
  100% {
    transform: translateY(-6.5em);
    opacity: 1;
  }
}
/*END OF BEER*/
/*COKTAIL*/
#cocktailglass {
  position: absolute;
  width: 5.5em;
  height: 11em;
  bottom: -5px;
  left: 50%;
  transform: translate3d(-50%, -0.2em, 0em) perspective(20em) rotateX(45deg);
  border-style: solid;
  border-color: var(--cocktail-glass);
  border-width: 0.2em 0.2em 0.8em 0.2em;
  border-radius: 0.1em 0.1em 3em 3em;
  background: linear-gradient(180deg, transparent 0%, transparent 30%, var(--cocktail1) 30%, var(--cocktail1) 50%, var(--cocktail2) 50%, var(--cocktail2) 80%, var(--cocktail3) 80%, var(--cocktail3) 100%);
  box-shadow: 0em 0em 0.1em var(--cocktail-glass);
  opacity: 0.9;
}

#glassfoot {
  position: absolute;
  bottom: 0;
  transform: translate3d(-50%, 0em, 0em);
  background-color: var(--cocktail-glass);
  width: 3em;
  height: 0.5em;
  left: 50%;
  border-radius: 1em 1em 0em 0em;
}

#straw {
  position: absolute;
  top: 0;
  transform: rotate(-15deg);
  background-color: var(--straw);
  width: 0.4em;
  height: 11em;
  left: 40%;
}
#straw:before, #straw:after {
  display: block;
  content: "";
  height: 100%;
  width: 0.1em;
  background-color: var(--straw-stripe);
  position: absolute;
  top: 0;
}
#straw:before {
  left: 0.03em;
}
#straw:after {
  left: 0.24em;
}

#cocktailbubble div {
  position: absolute;
  background-color: var(--cocktail1);
  width: 0.2em;
  height: 0.2em;
  border-radius: 50%;
  bottom: 7.3em;
  -webkit-animation-name: cocktailbubble;
          animation-name: cocktailbubble;
  -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
  -webkit-animation-timing-function: linear;
          animation-timing-function: linear;
}
#cocktailbubble div:nth-child(1) {
  left: 4.3em;
  -webkit-animation-duration: 0.28s;
          animation-duration: 0.28s;
}
#cocktailbubble div:nth-child(2) {
  left: 4.9em;
  -webkit-animation-duration: 0.32s;
          animation-duration: 0.32s;
}
#cocktailbubble div:nth-child(3) {
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0