纯css实现的城堡效果

代码语言:html

所属分类:布局界面

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


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
#tower {
  --sX: 60px;
  --sY: 60px;
  --sZ: 140px;
  --cF: #FFF;
  --cS: #F6F6F6;
}
#tower .face-front {
  border-top: 7px solid #E6E6E6;
  border-bottom: 10px solid #F6F6F6;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}
#tower .face-front .window {
  width: 40px;
  height: 40px;
  margin-top: 10px;
  background-color: #888;
  border-top: 2px solid #AAA;
  border-right: 7px solid #BBB;
  border-radius: 23px 23px 0 0;
}
#tower .face-front .door {
  width: 30px;
  height: 40px;
  margin-bottom: -10px;
  background-color: #B96;
  border-top: 1px solid #CCC;
  border-right: 5px solid #DDD;
  border-radius: 15px 15px 0 0;
}
#tower .face-side {
  border-right: 7px solid #BBB;
  border-left: 10px solid #DDD;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
#tower .face-side .window {
  width: 40px;
  height: 40px;
  margin-right: 10px;
  background-color: #666;
  border-top: 7px solid #BBB;
  border-right: 2px solid #AAA;
  border-radius: 0 23px 23px 0;
}

#tower-roof {
  --sX: 70px;
  --sY: 70px;
  --sZ: 100px;
  --pZ: 135px;
  --cF: #F96;
  --cS: #E74;
}

#left-wall {
  --sX: 80px;
  --sY: 240px;
  --sZ: 100px;
  --pX: 40px;
  --pY: -150px;
  --cS: #EEE;
  --cT: #E74;
}
#left-wall .face-side {
  padding: 45px 0;
  border-right: 5px solid #CCC;
  border-left: 10px solid #DDD;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}
#left-wall .face-side .window {
  width: 30px;
  height: 63px;
  background-color: #666;
  border-top: 2px solid #AAA;
  border-left: 7px solid #BBB;
  border-radius: 15px 15px 0 0;
  transform: rotate(90deg);
}
#left-wall .face-top {
  transform: translateZ(var(--sZ)) rotateY(-45deg) translateZ(33px);
}

#right-wall {
  --sX: 340px;
  --sY: 80px;
  --sZ: 60px;
  --pX: 200px;
  --pY: -40px;
  --cT: #F96;
  --cF: #FFF;
}
#right-wall .face-front {
  padding: 0 45px;
  display: flex;
  border-top: 7px solid #DDD;
  border-bottom: 10px solid #EEE;
  justify-content: space-around;
  align-items: center;
}
#right-wall .face-front .window {
  width: 30px;
  height: 33px;
  background-color: #888;
  border-top: 2px solid #BBB;
  border-right: 7px solid #CCC;
  border-radius: 15px 15px 0 0;
}
#right-wall .face-top {
  transform: translateZ(var(--sZ)) rotateX(-45deg) translateZ(33px);
}

#tree-1 {
  --sX: 80px;
  --sZ: 200px;
  --pX: -210px;
  --pY: -330px;
}

#tree-2 {
  --sX: 30px;
  --sZ: 75px;
  --pX: -130px;
  --pY: -130px;
}

#tree-3 {
  --sX: 60px;
  --sZ: 250px;
  --pX: 110px;
  --pY: -330px;
}

#tree-4 {
  --sX: 30px;
  --sZ: 75px;
  --pX: 200px;
  --pY: -200px;
}

* {
  box-sizing: border-box;
}

.figure-content {
  background-image: linear-gradient(125deg, #BEF, #FEB);
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 500px;
  transition: perspective 300ms;
}
.figure-content:hover {
  perspective: 750px;
}
.figure-content:hover .ground {
  transform: rotateX(100deg) translate3D(0, 50px, -155px) rotateZ(7deg);
}

.ground {
  width: 1000px;
  height: 1000px;
  background-color: #FEB;
  display: flex;
  justify-content: center;
  align-items: center;
  transform: rotateX(110deg) translate3D(0, 100px, -180px);
  transform-style: preserve-3d;
  transition: transform 300ms;
  flex: 0 0 auto;
}

.block, .pyramid {
  --pX: 0px;
  --pY: 0px;
  --pZ: 0px;
  width: var(--sX);
  height: var(--sY);
  transform: rotateZ(-45deg) translate3d(var(--pX), var(--pY), var(--pZ));
  transform-style: preserve-3d;
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0