css实现3d城市效果
代码语言:html
所属分类:三维
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D City Animation Pure CSS</title>
<style>
/* Variables */
:root {
--bg: #DBDBDB;
--gray: #393F4D;
--gray-l: #f5f5f5;
--cyan: #B6E4E6;
--green: #51E5FF;
--yellow: #FDE74C;
}
/* Reset */
*, *::after, *::before {
margin: 0;
padding: 0;
box-sizing: border-box;
text-rendering: optimizeLegibility;
user-select: none;
}
/* Tag */
html {
font-family: sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
min-height: 100vh;
background: var(--bg);
}
main {
min-width: 800px;
height: 300px;
position: relative;
transform-style: preserve-3d;
animation: rotate-container 10s infinite ease-in-out alternate;
}
/* Components */
.way {
position: absolute;
top: 0;
width: 350px;
height: 350px;
background: var(--gray);
border: 50px solid var(--gray-l);
transform: rotateX(90deg);
transform-style: preserve-3d;
border-radius: 15px;
box-shadow: 2px 2px 100px 0px rgba(0,0,0,0.1);
}
.way-l {
left: 0;
}
.way-r {
right: 0;
display: flex;
}
.ad {
position: absolute;
top: 150px;
left: 80px;
transform: rotateY(-20deg);
font-size: 10px;
padding: 2px 5px;
letter-spacing: 2px;
border-radius: 2px;
color: white;
background: var(--gray);
border: 1px solid white;
animation: ad-sale 1s linear infinite 1s;
}
.txt {
position: absolute;
top: 50px;
left: calc(50% - 75px);
width: 150px;
font-size: 20px;
padding: 3px 5px;
letter-spacing: 2px;
text-align: center;
color: white;
background: var(--gray);
border-radius: 4px;
box-shadow: 3px 3px 100px 3px rgba(0,0,0,0.2);
}
.way-r .cube {
height: 300px;
width: 100px;
transform:
rotateX(90deg)
rotateY(180deg)
rotateZ(180deg)
translateY(-80px)
translateX(20px)
translateZ(-10px)
scale(.5);;
}
.bridge {
width: 50px;
height: 100px;
background: var(--green);
position: absolute;
}
.bridge-l {
transform:
rotateX(90deg)
rotateZ(90deg)
translateY(-275px)
translateZ(-125px)
translateX(150px);
animation: move-bridge-l 15s linear infinite;
border-top: 5px solid var(--gray);
border-bottom: 5px solid var(--gray);
}
.bridge-r {
transform:.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0