纯css实现三维多层房屋滚动立体视觉差异效果代码

代码语言:html

所属分类:视觉差异

代码描述:纯css实现三维多层房屋滚动立体视觉差异效果代码,多层房间滚动向下展示房间内部文字,可以自定义房间内的5面墙壁的图片,实现更美的视觉差异滚动展示效果。

代码标签: css 大楼 滚动 房间 立体 视觉差异

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

<!doctype html>
<html>

<head>
    <meta charset="utf-8">

    <style>
        :root {
        	--depth: 500px;
        	--turnLeft: 0.06turn;
        	--turnRight: -0.06turn;
        	--turn: var(--turnRight);
        }
        
        *,
        *::before,
        *::after {
        	box-sizing: border-box;
        	margin: 0;
        	padding: 0;
        }
        
        html {
        	height: 100%;
        	overflow: hidden;
        }
        
        body {
        	height: 100%;
        	overflow-y: scroll;
          scroll-snap-type: y mandatory;
        	background: hsl(0 0% 10%);
        	perspective: 1000px;
        	perspective-origin: 50% 35%;
        }
        
        .building {
        	transform-style: preserve-3d;
        }
        
        .room {
        	position: relative;
        	border: 4vmax solid hsl(0 0% 10%);
        	height: 80vh;
        	width: 100vw;
        	scroll-snap-align: center;
        	transform-style: preserve-3d;
        }
        
        .room + .room {
        	border-top: 0;
        }
        
        .room::before,
        .room::after {
        	content: '';
        	position: absolute;
        	height: var(--depth);
        	width: 100%;
        	backface-visibility: hidden;
        }
        
        .room::before {
        	background:
        		radial-gradient(hsl(0 0% 100% / 10%), hsl(0 0% 0% / 10%)),
        		lightgray;
        	transform: rotatex(-90deg) scale(1.001);
        	transform-origin: center top;
        }
        
        .room::after {
        	bottom: 0;
        	background:
        		radial-gradient(hsl(0 0% 100% / 10%), hsl(0 0% 0% / 10%)),
        		url() center / cover,
        		sandybrown;
        	transform: rotatex(90deg);
        	transform-origin: center bottom;
        }
        
        .room-walls {
        	position: absolute;
        	inset: 0;
        	background:
        		linear-gradient(to top, hsl(0 0% 90%) 2.5vh, transparent 0),
        		radial-gradient(hsl(0 0% 0% / 30%), hsl(0 0% 0% / 50%)),
        		url() center / cover,
        		darkgray;
        	transform: translatez(calc(var(--depth) * -1));
        	transform-style: preserve-3d;
        }
        
        .room-walls::before,
        .room-walls::after {
        	content: '';
        	position: absolute;
        	height: 100%;
        	width: var(--depth);
        }
        
        .room-walls::before {
        	right: 100%;
        	background:
        		linear-gradient(to top, hsl(0 0% 75%) 2.5vh, transparent 0),
        		radial-gradient(hsl(0 0% 100% / 10%), hsl(0 0% 0% / 10%)),
        		url() center / cover,
        		gray;
        	transform: rotatey(.........完整代码请登录后点击上方下载按钮下载查看

网友评论0