纯css+div布局实现一个三维客厅效果
代码语言:html
所属分类:布局界面
代码描述:纯css+div布局实现一个三维客厅效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
/***********************/
/***********************/
/************************/
/* Mixin para crear cubo ( Caras siempre al frente ) */
/************************/
/***********************/
/***********************/
/**/
*, *::after, *::before {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
transform-style: preserve-3d;
-webkit-tap-highlight-color: transparent;
}
/* Generic */
body {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
overflow: hidden;
background-image: radial-gradient(circle, #171424, black);
}
.face {
position: absolute;
}
/***************/
.house {
position: absolute;
width: 28vw;
height: 28vw;
transform: perspective(1250px) rotateX(75deg) rotateZ(45deg) translateZ(-9vw);
}
.h-shadow {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-shadow: 1.5vw -3vw 3vw black, 1.5vw 0.5vw 1.5vw black;
}
.h-lights {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
width: 45vw;
height: 45vw;
}
.h-light {
position: absolute;
}
.h-light:nth-of-type(1) {
bottom: 5vw;
right: 0;
width: 14vw;
height: 14vw;
border-radius: 50%;
background-image: radial-gradient(#1b182a, transparent);
filter: blur(1vw);
}
.h-light:nth-of-type(2) {
bottom: 18vw;
right: -1vw;
width: 2vw;
height: 12vw;
border-radius: 50%;
transform: rotateZ(-50deg);
background-image: radial-gradient(rgba(81, 137, 251, 0.45) 50%, rgba(40, 125, 210, 0.45), transparent);
box-shadow: -1vw -1vw 2vw 1vw rgba(131, 171, 252, 0.1);
filter: blur(1vw);
}
.h-light:nth-of-type(3) {
bottom: -2vw;
right: 17vw;
width: 5vw;
height: 12vw;
border-radius: 50%;
transform: rotateZ(-50deg);
background-image: radial-gradient(rgba(81, 137, 251, 0.5) 50%, rgba(40, 125, 210, 0.5), transparent);
filter: blur(2vw);
}
.h-light:nth-of-type(3)::before, .h-light:nth-of-type(3)::after {
content: '';
position: absolute;
width: 200%;
top: -6vw;
height: 400%;
background-image: linear-gradient(to bottom, rgba(40, 125, 210, 0.1), rgba(81, 137, 251, 0.1), transparent);
border-top-left-radius: 10vw;
border-top-right-radius: 10vw;
filter: blur(1.5vw);
}
.h-light:nth-of-type(3)::before {
right: -50%;
transform-origin: top right;
transform: rotateZ(15deg);
box-shadow: -2vw -2vw 0 rgba(81, 137, 251, 0.075);
}
.h-light:nth-of-type(3)::after {
left: -50%;
transform-origin: top left;
transform: rotateZ(-15deg);
box-shadow: 2vw -2vw 0 rgba(81, 137, 251, 0.075);
}
.h-light:nth-of-type(4) {
bottom: 5vw;
left: 8vw;
width: 28vw;
height: 4vw;
transform-origin: top left;
transform: skewX(58deg);
background-image: linear-gradient(to right, rgba(81, 137, 251, 0.075) 10%, transparent 25%, transparent, rgba(0, 0, 0, 0.15));
filter: blur(0.25vw);
}
.h-light:nth-of-type(6) {
bottom: 14vw;
right: 2vw;
width: 8vw;
height: 16vw;
transform-origin: bottom left;
transform: skewY(49deg);
background-image: linear-gradient(to left, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.7));
filter: blur(0.35vw);
}
/***************/
/***************/
.alt {
position: absolute;
left: 0;
top: 0;
width: 27vw;
height: 27vw;
}
.alt__front {
width: 27vw;
height: 0.5vw;
transform-origin: bottom left;
transform: rotateX(-90deg) translateZ(26.5vw);
}
.alt__back {
width: 27vw;
height: 0.5vw;
transform-origin: top left;
transform: rotateX(-90deg) rotateY(180deg) translateX(-27vw) translateY(-0.5vw);
}
.alt__right {
width: 27vw;
height: 0.5vw;
transform-origin: top left;
transform: rotateY(90deg) rotateZ(-90deg) translateZ(27vw) translateX(-27vw) translateY(-0.5vw);
}
.alt__left {
width: 27vw;
height: 0.5vw;
transform-origin: top left;
transform: rotateY(-90deg) rotateZ(90deg) translateY(-0.5vw);
}
.alt__top {
width: 27vw;
height: 27vw;
transform-origin: top left;
transform: translateZ(0.5vw);
}
.alt__bottom {
width: 27vw;
height: 27vw;
transform-origin: top left;
transform: rotateY(180deg) translateX(-27vw);
}
.alt__front {
background-color: #9E99C1;
}
.alt__back {
background-color: #383358;
}
.alt__right {
background-color: #383358;
}
.alt__left {
background-color: #FBFAFE;
}
.alt__top {
background-image: linear-gradient(to bottom, #0b0c1f, #383358, #9E99C1);
}
.alt__top .light:nth-of-type(1) {
position: absolute;
height: 100%;
width: 100%;
background-image: linear-gradient(to bottom, rgba(20, 61, 103, 0.75), rgba(81, 137, 251, 0.75), transparent);
}
.alt__top .light:nth-of-type(2) {
position: absolute;
left: 4vw;
height: 100%;
width: 6vw;
background-image: linear-gradient(to bottom, transparent 20%, rgba(40, 125, 210, 0.75), rgba(81, 137, 251, 0.25) 80%);
filter: blur(0.1vw);
}
.alt__top .light:nth-of-type(3) {
position: absolute;
bottom: 10vw;
left: 5vw;
width: 6vw;
height: 3vw;
border-radius: 50%;
transform: rotateZ(42deg);
background-image: radial-gradient(rgba(131, 171, 252, 0.75) 50%, rgba(32, 99, 167, 0.75));
filter: blur(0.55vw);
}
.alt__top .light:nth-of-type(4) {
position: absolute;
bottom: 7vw;
left: 4vw;
width: 8.5vw;
height: 2vw;
border-radius: 50%;
transform: rotateZ(40deg);
background-image: radial-gradient(rgba(131, 171, 252, 0.75) 50%, rgba(32, 99, 167, 0.75));
filter: blur(0.55vw);
}
.alt__top .light:nth-of-type(5) {
position: absolute;
bottom: 3.5vw;
left: 4.5vw;
width: 6vw;
height: 2vw;
border-radius: 50%;
transform: rotateZ(40deg);
background-image: radial-gradient(rgba(141, 178, 252, 0.75) 50%, rgba(32, 99, 167, 0.75));
filter: blur(0.75vw);
}
.alt__top .light:nth-of-type(6) {
position: absolute;
bottom: 3vw;
left: .5vw;
width: 4vw;
height: 2vw;
border-radius: 50%;
transform: rotateZ(40deg);
background-image: radial-gradient(rgba(141, 178, 252, 0.75) 50%, rgba(32, 99, 167, 0.75));
filter: blur(0.35vw);
}
.alt__top .light:nth-of-type(7) {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(to right, black, #5189fb 10%, transparent 20%);
}
.alt__top .light:nth-of-type(7)::before {
content: '';
position: absolute;
width: 20%;
height: 100%;
background-image: linear-gradient(to right, rgba(5, 70, 199, 0.6), transparent 60%);
}
.alt__top .light:nth-of-type(7)::after {
content: '';
position: absolute;
width: 100%;
height: 20%;
background-image: linear-gradient(to bottom, rgba(6, 78, 224, 0.5), transparent 60%);
}
.alt__top .light:nth-of-type(8) {
position: absolute;
bottom: 5vw;
left: 10vw;
width: 6vw;
height: 4vw;
border-radius: 50%;
transform: rotateZ(40deg);
background-image: radial-gradient(rgba(255, 255, 255, 0.1) 50%, rgba(128, 121, 174, 0.1));
filter: blur(0.8vw);
}
.alt__bottom {
background-color: #383358;
}
.alb {
position: absolute;
left: 0;
bottom: 0;
width: 27vw;
height: 1vw;
}
.alb__front {
width: 27vw;
height: 2vw;
transform-origin: bottom left;
transform: rotateX(-90deg) translateZ(-1vw);
}
.alb__back {
width: 27vw;
height: 2vw;
transform-origin: top left;
transform: rotateX(-90deg) rotateY(180deg) translateX(-27vw) translateY(-2vw);
}
.alb__right {
width: 1vw;
height: 2vw;
transform-origin: top left;
transform: rotateY(90deg) rotateZ(-90deg) translateZ(27vw) translateX(-1vw) translateY(-2vw);
}
.alb__left {
width: 1vw;
height: 2vw;
transform-origin: top left;
transform: rotateY(-90deg) rotateZ(90deg) translateY(-2vw);
}
.alb__top {
width: 27vw;
height: 1vw;
transform-origin: top left;
transform: translateZ(2vw);
}
.alb__bottom {
width: 27vw;
height: 1vw;
transform-origin: top left;
transform: rotateY(180deg) translateX(-27vw);
}
.alb__front {
background-image: linear-gradient(to right, #9E99C1 40%, #8f89b7);
}
.alb__back {
background-color: #383358;
}
.alb__right {
background-color: #383358;
}
.alb__left {
background-color: #FBFAFE;
}
.alb__top {
background-image: linear-gradient(to right, #FBFAFE 40%, #eae5fa);
}
.alb__bottom {
background-color: #383358;
}
.arb {
position: absolute;
right: 0;
bottom: 0;
width: 1vw;
height: 28vw;
}
.arb__front {
width: 1vw;
height: 2vw;
transform-origin: bottom left;
transform: rotateX(-90deg) translateZ(26vw);
}
.arb__back {
width: 1vw;
height: 2vw;
transform-origin: top left;
transform: rotateX(-90deg) rotateY(180deg) translateX(-1vw) translateY(-2vw);
}
.arb__right {
width: 28vw;
height: 2vw;
transform-origin: top left;
transform: rotateY(90deg) rotateZ(-90deg) translateZ(1vw) translateX(-28vw) translateY(-2vw);
}
.arb__left {
width: 28vw;
height: 2vw;
transform-origin: top left;
transform: rotateY(-90deg) rotateZ(90deg) translateY(-2vw);
}
.arb__top {
width: 1vw;
height: 28vw;
transform-origin: top left;
transform: translateZ(2vw);
}
.arb__bottom {
width: 1vw;
height: 28vw;
transform-origin: top left;
transform: rotateY(180deg) translateX(-1vw);
}
.arb__front {
background-color: #8f89b7;
}
.arb__back {
background-color: #383358;
}
.arb__right {
background-image: linear-gradient(to right, #282347 40%, #0f0e17);
}
.arb__left {
background-color: #9E99C1;
}
.arb__top {
background-image: linear-gradient(to top, #FBFAFE, #3b3469 25%, #2e2a48 75%, #9E99C1);
}
.arb__top::before {
content: '';
position: absolute;
width: 100%;
height: 30%;
top: 0;
background-image: linear-gradient(to bottom, transparent, rgba(81, 137, 251, 0.85), transparent);
}
.arb__bottom {
background-color: #383358;
}
/***************/
/***************/
.blt {
position: absolute;
left: 0;
top: 0;
width: 1vw;
height: 27vw;
transform: translateZ(0.5vw);
}
.blt__front {
width: 1vw;
height: 20vw;
transform-origin: bottom left;
transform: rotateX(-90deg) translateZ(7vw);
}
.blt__back {
width: 1vw;
height: 20vw;
transform-origin: top left;
transform: rotateX(-90deg) rotateY(180deg) translateX(-1vw) translateY(-20vw);
}
.blt__right {
width: 27vw;
height: 20vw;
transform-origin: top left;
transform: rotateY(90deg) rotateZ(-90deg) translateZ(1vw) translateX(-27vw) translateY(-20vw);
}
.blt__left {
width: 27vw;
height: 20vw;
transform-origin: top left;
transform: rotateY(-90deg) rotateZ(90deg) translateY(-20vw);
}
.blt__top {
width: 1vw;
height: 27vw;
transform-origin: top left;
transform: translateZ(20vw);
}
.blt__bottom {
width: 1vw;
height: 27vw;
transform-origin: top left;
transform: rotateY(180deg) translateX(-1vw);
}
.blt__front {
background-image: linear-gradient(to bottom, #383358, #9E99C1);
}
.blt__back {
background-color: #383358;
}
.blt__right {
background-image: linear-gradient(to bottom, #151225, #383358, #383358 90%, #242040);
}
.blt__right::before {
content: '';
position: absolute;
bottom: 0;
width: 100%;
height: .75vw;
background-image: linear-gradient(to bottom, #8f89b7, #287dd2);
border-top: 0.1vw solid #282347;
border-bottom: 0.1vw solid #282347;
}
.blt__right::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
background-image: linear-gradient(to bottom, rgba(6, 78, 224, 0.35), transparent 30%, transparent 70%, rgba(40, 125, 210, 0.35));
}
.blt__left {
background-color: #FBFAFE;
}
.blt__bottom {
background-color: #383358;
}
.blt2 {
position: absolute;
left: 0;
top: 0;
width: 2vw;
height: 27vw;
transform: translateZ(20.5vw);
}
.blt2__front {
width: 2vw;
height: 0.75vw;
transform-origin: bottom left;
transform: rotateX(-90deg) translateZ(26.25vw);
}
.blt2__back {
width: 2vw;
height: 0.75vw;
transform-origin: top left;
transform: rotateX(-90deg) rotateY(180deg) translateX(-2vw) translateY(-0.75vw);
}
.blt2__right {
width: 27vw;
height: 0.75vw;
transform-origin: top left;
transform: rotateY(90deg) rotateZ(-90deg) translateZ(2vw) translateX(-27vw) translateY(-0.75vw);
}
.blt2__left {
width: 27vw;
height: 0.75vw;
transform-origin: top left;
transform: rotateY(-90deg) rotateZ(90deg) translateY(-0.75vw);
}
.blt2__top {
width: 2vw;
height: 27vw;
transform-origin: top left;
transform: translat.........完整代码请登录后点击上方下载按钮下载查看
网友评论0