利用位置偏移居中

<template>
<div class="root" @touchmove.prevent>
<div class="card">
<div class="close" @click="onClose"><i class="fa fa-times" aria-hidden="true"></i></div>
</div>
</div>
</template>

<script>
export default {
name: 'InsuredDetailDialog',
props: {
data: {
type: String,
default: ''
}
},
methods: {
onClose () {
this.$emit('onClose', null)
}
}
}
</script>

<style scoped>
.root {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
z-index: 9999;
}

.card {
background: #FFFFFF;
border-radius: 16px;
width: 80%;
height: 90%;
margin: 0 auto;
position: relative;
top: 50%;
transform: translateY(-50%);
}

.close {
position: absolute;
right: 1rem;
top: 0.5rem;
}
</style>

posted @ 2019-06-25 09:30  飞晨信息  阅读(179)  评论(0)    收藏  举报