兄弟选择器 +

2019-11-14  本文已影响0人  Wrestle_Mania
<template lang="html">
  <div class="">
    <div class="peng" flex="main:center cross:center">
      我是捧哏
    </div>
    <div class="dou" flex="main:center cross:center">
      我是逗哏
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {},
  watch: {},
  components: {}
};
</script>

<style lang="scss" scoped>
.peng {
  width: 100px;
  height: 40px;
  background: red;
  color: #fff;
  margin-bottom: 20px;
  &:hover + .dou {
    background: blue;
    width: 500px;
    height: 500px;
    font-size: 50px;
  }
}
.dou {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  background: red;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  transition: all 1s;
}
</style>

还是很有趣的,这个选择器我还是第一次用

升级版本

<template lang="html">
  <div class="wrapper" flex="main:center cross:center">
    <div flex="cross:center">
      <div class="peng" flex="main:center cross:center">
        我是捧哏
      </div>
      <div class="dou same" flex="main:center cross:center">
        我是逗哏
      </div>
      <div class="peng-dou same" flex="main:center cross:center">
        论捧逗
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {},
  watch: {},
  components: {}
};
</script>

<style lang="scss" scoped>
.wrapper {
  height: 100vh;
  .peng {
    width: 100px;
    height: 40px;
    background: red;
    color: #fff;
    margin-right: 30px;
    order: 2;
    &:hover + .dou {
      background: blue;
      width: 500px;
      height: 500px;
      font-size: 50px;
    }
    &:hover + .dou + .peng-dou {
      background: orange;
      width: 500px;
      height: 500px;
      font-size: 50px;
    }
  }
  .same {
    border-radius: 20px;
    color: #fff;
    font-size: 20px;
    transition: all 1s;
    font-weight: bold;
  }
  .dou {
    width: 100px;
    height: 100px;
    order: 1;
    background: red;
    margin-right: 30px;
  }
  .peng-dou {
    width: 200px;
    height: 200px;
    background: pink;
    order: 3;
  }
}
</style>

只能往后找,并且可以叠加&:hover + .dou + .peng-dou

发现了一个问题,flex.css无法设置order,只能在css中去设置

上一篇 下一篇

猜你喜欢

热点阅读