123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <div class="air-door-container" @click="toggleDoor">
- <div class="tunnel">
- <!-- 巷道顶部 -->
- <div class="tunnel-top"></div>
-
- <!-- 巷道底部 -->
- <div class="tunnel-bottom"></div>
-
- <!-- 门框 -->
- <div class="door-frame"></div>
-
- <!-- 左右两扇门 -->
- <div class="doors-container">
- <!-- 左门 (向内开) -->
- <div
- class="door left-door"
- :class="{ 'open': isOpen }"
- ></div>
-
- <!-- 右门 (向外开) -->
- <div
- class="door right-door"
- :class="{ 'open': isOpen }"
- ></div>
- </div>
- </div>
- <div class="status">
- {{ isOpen ? '风门开启' : '风门关闭' }}
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { ref } from 'vue';
- const isOpen = ref(false);
- const toggleDoor = () => {
- isOpen.value = !isOpen.value;
- };
- </script>
- <style scoped>
- .air-door-container {
- position: relative;
- width: 800px;
- height: 400px;
- margin: 0 auto;
- perspective: 1000px;
- }
- .tunnel {
- position: relative;
- width: 100%;
- height: 100%;
- transform-style: preserve-3d;
- }
- .tunnel-top {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 120px;
- background: linear-gradient(to right, #222, #444, #222);
- border-radius: 400px 400px 0 0 / 60px 60px 0 0;
- }
- .tunnel-bottom {
- position: absolute;
- top: 120px;
- left: 0;
- width: 100%;
- height: 300px;
- /* background-image: linear-gradient(45deg, #333 25%, #444 25%, #444 50%, #333 50%, #333 75%, #444 75%, #444 100%); */
- background-size: 40px 40px;
- }
- .door-frame {
- position: absolute;
- top: 120px;
- left: 0;
- width: 100%;
- height: 300px;
- border: 8px solid #8B4513;
- border-radius: 0 0 20px 20px / 0 0 10px 10px;
- box-sizing: border-box;
- z-index: 10;
- }
- .doors-container {
- position: absolute;
- top: 120px;
- left:0;
- width: 100%;
- height: 300px;
- transform-style: preserve-3d;
- z-index: 20;
- }
- .door {
- position: absolute;
- top: 8px;
- width: calc(50% - 8px);
- height: calc(100% - 16px);
- background-color: #A9A9A9;
- border: 2px solid #696969;
- box-sizing: border-box;
- transition: transform 2s ease;
- transform-origin: left center;
- transform-style: preserve-3d;
- }
- .left-door {
- left: 8px;
- /* border-radius: 0 0 0 10px / 0 0 0 5px; */
- }
- .right-door {
- right: 8px;
- /* border-radius: 0 0 10px 0 / 0 0 5px 0; */
- transform-origin: right center;
- }
- .door.open.left-door {
- transform: rotateY(-90deg);
- }
- .door.open.right-door {
- transform: rotateY(-90deg);
- }
- /* 门的纹理 */
- .door::before,
- .door::after {
- content: '';
- position: absolute;
- background-color: #696969;
- }
- .left-door::before {
- top: 10px;
- left: 37px;
- width: 1px;
- height: 100px;
- }
- .left-door::after {
- top: 40px;
- left: 10px;
- width: 130px;
- height: 1px;
- }
- .right-door::before {
- top: 10px;
- right: 37px;
- width: 1px;
- height: 100px;
- }
- .right-door::after {
- top: 40px;
- right: 10px;
- width: 130px;
- height: 1px;
- }
- .status {
- position: absolute;
- top: 10px;
- left: 0;
- width: 100%;
- text-align: center;
- font-size: 18px;
- font-weight: bold;
- color: #fff;
- text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
- }
- </style>
|