CSS3 transition 属性 实现地图切换

话不多说,直接上图,我查看了百度地图的然后试着做了一个具有收缩功能的

<template>
  <div id="mapType">
    <div class="mapTypeCard vectorType">
      <span>地图</span>
    </div>
    <div class="mapTypeCard imgType">
      <span>影像</span>
    </div>
    <div class="mapTypeCard terType">
      <span>地形</span>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {};
  },
  methods: {},
  mounted() {}
};
</script>
<style scoped>
#mapType {
  width: 106px;
  height: 70px;
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 2;
  cursor: pointer;
  border-radius: 5px;
  transition: width 0.8s, height 0.8s;
  -moz-transition: width 0.8s, height 0.8s, -moz-transform 0.8s; /* Firefox 4 */
  -webkit-transition: width 0.8s, height 0.8s, -webkit-transform 0.8s; /* Safari and Chrome */
  -o-transition: width 0.8s, height 0.8s, -o-transform 0.8s; /* Opera */
}
#mapType:hover {
  width: 288px;
  background: rgba(255, 255, 255, 0.3);
}
#mapType .mapTypeCard {
  position: absolute;
  top: 5px;
  width: 86px;
  height: 60px;
  border-radius: 5px;
  border: solid 1px black;
}
#mapType .mapTypeCard span {
  width: 36px;
  height: 16px;
  position: absolute;
  bottom: 1px;
  right: 1px;
  display: inline-block;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  color: #fff;
  background: #888f88;
  opacity: 0.8;
}
#mapType .vectorType {
  background-color: pink;
  z-index: 3;
  right: 15px;
  transition: right 0.8s;
  -moz-transition: right 0.8s; /* Firefox 4 */
  -webkit-transition: right 0.8s; /* Safari and Chrome */
  -o-transition: right 0.8s; /* Opera */
}
#mapType .imgType {
  z-index: 2;
  right: 10px;
  background-color: rgb(118, 118, 201);
  transition: right 0.8s;
  -moz-transition: right 0.8s; /* Firefox 4 */
  -webkit-transition: right 0.8s; /* Safari and Chrome */
  -o-transition: right 0.8s; /* Opera */
}
#mapType .terType {
  z-index: 1;
  right: 5px;
  background-color: greenyellow;
  transition: right 0.8s;
  -moz-transition: right 0.8s; /* Firefox 4 */
  -webkit-transition: right 0.8s; /* Safari and Chrome */
  -o-transition: right 0.8s; /* Opera */
  transition: right 0.8s;
  -moz-transition: right 0.8s; /* Firefox 4 */
  -webkit-transition: right 0.8s; /* Safari 和 Chrome */
  -o-transition: right 0.8s; /* Opera */
}
#mapType:hover .vectorType {
  right: 197px;
}
#mapType:hover .imgType {
  right: 101px;
}
#mapType:hover .terType {
  right: 5px;
}
#mapType .vectorType:hover,
#mapType .active {
  border: solid 1px #31a5f7;
}
#mapType .imgType:hover {
  border: solid 1px #31a5f7;
}
#mapType .terType:hover {
  border: solid 1px #31a5f7;
}
#mapType .vectorType:hover span,
#mapType .active span {
  background: #31a5f7;
}
#mapType .imgType:hover span {
  background: #31a5f7;
}
#mapType .terType:hover span {
  background: #31a5f7;
}
</style>

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

侧耳倾听...

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值