Last active
October 14, 2018 14:09
-
-
Save wzc0x0/868ed4aaec133fce3ed07e01ab85c285 to your computer and use it in GitHub Desktop.
dialog.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<div class="page"> | |
<button @click="isShow = true">点击</button> | |
</div> | |
<transition name="fade"> | |
<div class="dialog" v-if="isShow" @click="isShow = false"> | |
<div class="dialog-overlay"></div> | |
<div class="dialog-content"> | |
<div class="box"></div> | |
</div> | |
</div> | |
</transition> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
isShow: false | |
} | |
}, | |
methods: { | |
test() {} | |
} | |
} | |
</script> | |
<style> | |
.fade-enter-active { | |
animation: fade-in .25s; | |
animation-fill-mode: forwards; | |
} | |
.fade-enter-active .dialog-content { | |
animation: zoom-in .25s; | |
animation-fill-mode: forwards; | |
} | |
.fade-leave-active { | |
animation: fade-out .25s; | |
animation-fill-mode: forwards; | |
} | |
</style> | |
<style> | |
html, | |
body { | |
height: 100%; | |
height: 100%; | |
} | |
.dialog { | |
position: fixed; | |
left: 0; | |
top: 0; | |
z-index: 10001; | |
width: 100%; | |
height: 100%; | |
} | |
.dialog-overlay { | |
position: absolute; | |
top: 0; | |
left: 0; | |
z-index: 10002; | |
width: 100%; | |
height: 100%; | |
background-color: rgba(0, 0, 0, 0.5); | |
} | |
.dialog-content { | |
position: absolute; | |
width: 90%; | |
top: 50%; | |
left: 50%; | |
z-index: 10003; | |
-webkit-transform: translate(-50%, -50%); | |
-ms-transform: translate(-50%, -50%); | |
transform: translate(-50%, -50%); | |
line-height: 1.5; | |
background-color: rgba(255, 255, 255, 0.95); | |
border-radius: 10px; | |
} | |
.dialog-content * { | |
box-sizing: border-box; | |
-webkit-box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
border: 0; | |
outline: none; | |
-moz-user-select: none; | |
-webkit-tap-highlight-color: transparent; | |
font-family: Helvetica; | |
font-size: 15px; | |
} | |
.dialog-open .dialog-overlay { | |
-webkit-animation-name: fade-in; | |
animation-name: fade-in; | |
} | |
.dialog-open .dialog-content { | |
-webkit-animation-name: zoom-in; | |
animation-name: zoom-in; | |
} | |
.dialog-open .dialog-overlay, | |
.dialog-open .dialog-content { | |
-webkit-animation-duration: 0.25s; | |
animation-duration: 0.25s; | |
-webkit-animation-fill-mode: forwards; | |
animation-fill-mode: forwards; | |
} | |
@keyframes fade-in { | |
0% { | |
opacity: 0; | |
} | |
100% { | |
opacity: 1; | |
} | |
} | |
@keyframes zoom-in { | |
0% { | |
opacity: 0; | |
-webkit-transform: translate(-50%, -50%) scale(1.2, 1.2); | |
transform: translate(-50%, -50%) scale(1.2, 1.2); | |
} | |
100% { | |
opacity: 1; | |
-webkit-transform: translate(-50%, -50%) scale(1, 1); | |
transform: translate(-50%, -50%) scale(1, 1); | |
} | |
} | |
@keyframes fade-out { | |
0% { | |
opacity: 1; | |
} | |
100% { | |
opacity: 0; | |
} | |
} | |
.box { | |
width: 90%; | |
height: 300px; | |
} | |
.page { | |
height: 2000px; | |
} | |
.show { | |
display: block; | |
} | |
.body-no-scroll { | |
position: absolute; | |
overflow: hidden; | |
width: 100%; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment