작성
·
161
0
저는 이런 문제가 생길때는 이렇게 코드를 작성했었는데 혹시 나쁜 방식인지 여쭤보고 싶습니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="css/reset.css">
<style media="screen">
input[name*="door-trigger"] {
display: none;
}
.stage {
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
background: #333;
}
.door {
position: relative;
width: 100px;
height: 150px;
perspective: 800px;
}
.door-back {
overflow: hidden;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: black;
}
.ilbuni {
position: absolute;
bottom: 0;
width: 100px;
height: 100px;
background-repeat: no-repeat;
background-position: 50% 50%;
background-size: contain;
transform: translate3d(100%, 0, 0);
transition: 0.5s 0.5s;
}
.door:nth-Child(1) .ilbuni {
background-image: url('images/ilbuni_0.png');
}
.door:nth-Child(2) .ilbuni {
background-image: url('images/ilbuni_1.png');
}
.door:nth-Child(3) .ilbuni {
background-image: url('images/ilbuni_2.png');
}
.door-body {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
transition: 0.5s;
transform-origin: 0%;
}
.door:nth-Child(1) .door-body {
background: rgba(255, 0, 0, 0.7);
}
.door:nth-Child(2) .door-body {
background: rgba(0, 255, 0, 0.7);
}
.door:nth-Child(3) .door-body {
background: rgba(0, 0, 255, 0.7);
}
#door-trigger01:checked ~ .stage .door:nth-child(1) .ilbuni {
transform: translate3d(0, 0, 0);
}
#door-trigger01:checked ~ .stage .door:nth-child(1) .door-body {
transform: rotateY(-120deg);
}
#door-trigger02:checked ~ .stage .door:nth-child(2) .ilbuni {
transform: translate3d(0, 0, 0);
}
#door-trigger02:checked ~ .stage .door:nth-child(2) .door-body {
transform: rotateY(-120deg);
}
#door-trigger03:checked ~ .stage .door:nth-child(3) .ilbuni {
transform: translate3d(0, 0, 0);
}
#door-trigger03:checked ~ .stage .door:nth-child(3) .door-body {
transform: rotateY(-120deg);
}
</style>
</head>
<body>
<input type="radio" name="door-trigger" id="door-trigger01">
<input type="radio" name="door-trigger" id="door-trigger02" checked>
<input type="radio" name="door-trigger" id="door-trigger03">
<div class="stage">
<label for="door-trigger01" class="door">
<div class="door-back">
<div class="ilbuni"></div>
</div>
<div class="door-body"></div>
</label>
<label for="door-trigger02" class="door">
<div class="door-back">
<div class="ilbuni"></div>
</div>
<div class="door-body"></div>
</label>
<label for="door-trigger03" class="door">
<div class="door-back">
<div class="ilbuni"></div>
</div>
<div class="door-body"></div>
</label>
</div>
</body>
</html>