实现效果
就是一个纯css实现的效果,话不多说 直接上代码
<template>
<div :class="openCloseOnoff ? 'rightsideBar sideBarOpen' : 'rightsideBar rightsideBarClose'">
<div class="openClose" @click="handleOpenClose"></div>
<div class="top">
<el-container>
<el-header>详细信息</el-header>
</el-container>
</div>
</div>
</template>
<script>
export default {
name: 'RightSidebar',
data () {
return {
openCloseOnoff: true
}
},
methods: {
// 展开或收缩侧边栏
handleOpenClose () {
this.openCloseOnoff = !this.openCloseOnoff
}
}
}
</script>
<style lang="scss">
.rightsideBar {
width: 350px;
height: 80%;
background: rgba(84, 92, 100, 0.7);
position: absolute;
transition: right 0.5s ease;
z-index: 10;
right: 0;
top: 110px;
.openClose {
width: 30px;
height: 81px;
background: url(../../assets/img/open.png) no-repeat center center;
position: absolute;
right: 324px;
top: 50%;
margin-top: -40px;
cursor: pointer;
}
.top {
.el-header {
background-color: #545c64;
color: #fff;
text-align: center;
line-height: 60px;
}
}
}
.rightsideBarClose {
right: -350px;
.openClose {
background: url(../../assets/img/close.png) no-repeat center center;
}
}
</style>
打开和关闭的两张图片