css - Vuetify - 悬停卡扩展 : Other cards are not resizing

标签 css vuetify.js

我正在使用 Vuetify 并在悬停时创建自定义可扩展卡片。当您将鼠标悬停在 v-card 上时,我试图让其他人变小,但它不起作用。

我只使用 CSS,这是 Codepen:https://codepen.io/fabiozanchi/pen/BeewPP

这里是代码:

.custom-card-1,
.custom-card-2,
.custom-card-3,
.custom-card-4 {
  width: 23%;
  margin: 0 1%;
  position: relative;
  float: left;
  transition: 0.4s;
  height: 350px;
}

.custom-card-1:hover {
  width: 68%;
}

.custom-card-1:hover .custom-card-2,
.custom-card-1:hover .custom-card-3,
.custom-card-1:hover .custom-card-4 {
  width: 8%;
  transition: 0.4s;
}

.custom-card-1:hover .custom-card-2 .card-content,
.custom-card-1:hover .custom-card-3 .card-content,
.custom-card-1:hover .custom-card-4 .card-content {
  display: none;
}
<div id="app">
  <v-app id="inspire">
    <v-layout row wrap>
      <v-flex xs12>
        <v-card elevation-2 class="custom-card-1">
          <v-container fluid class="card-content">
            <v-layout row wrap text-xs-center>
              <v-flex xs12>
                <p class="subheading xs12">lorem Ipsum 1</p>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
        <v-card elevation-2 class="custom-card-2">
          <v-container fluid class="card-content">
            <v-layout row wrap text-xs-center>
              <v-flex xs12>
                <p class="subheading xs12">lorem Ipsum 2</p>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
        <v-card elevation-2 class="custom-card-3">
          <v-container fluid class="card-content">
            <v-layout row wrap text-xs-center>
              <v-flex xs12>
                <p class="subheading xs12">lorem Ipsum 3</p>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
        <v-card elevation-2 class="custom-card-4">
          <v-container fluid class="card-content">
            <v-layout row wrap text-xs-center>
              <v-flex xs12>
                <p class="subheading xs12">lorem Ipsum 4</p>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
      </v-flex>
    </v-layout>
  </v-app>
</div>

知道如何让它只与 CSS 一起工作吗?

由于百分比宽度,目前卡片将转到另一行。

最佳答案

只需要对您的 CSS 代码进行少量更改。您的悬停选择器有点不对。它应该像 .custom-card-1:hover ~ .custom-card-2 因为 custom-card-1custom-card-2 都是兄弟元素。检查这个Demo :

关于css - Vuetify - 悬停卡扩展 : Other cards are not resizing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56471030/

相关文章:

html - 删除位置 :absolute magically makes text underlined

html - 使用另一个布局选项而不是表格

css - 覆盖 Vuetify Icon 组件

vue.js - 防止开关切换并在 Vuetify 中显示警告消息 v-switch

html - 具有相对定位的 CSS div 在 IE 中无法正常工作

jquery 灯箱事件未触发

vuetify.js - 虚拟化 3 : How to define button font size based on button size?

vue.js - 无法获得 textarea 的 scrollHeight 的正确值 - VueJs,Vuetify

javascript - 出现此错误 : Cannot read property 'length' of undefined

css - 媒体查询不会在 iphone 4 和 iphone 5s 的旋转中更新