我希望该v卡是透明的,但其中的内容不应透明。如何使用CSS制作
?card.vue
<v-card class="cardColor">
<v-card-text>
TEXT
</v-card-text>
<v-card-actions>
<v-btn color="primary" @click="foo">Button</v-btn>
</v-card-actions>
</v-card>
common.css
.cardColor {
background-color: white!important;
border-color: transparent!important;
opacity: 0.65;
}
我试图写这个,但是没有用。
.cardColor {
color: rgba(255, 255, 255, 0.5);
}
答案 0 :(得分:1)
我对卡片背景设置了透明层并去除了不透明性,这就是您所需要的吗?
new Vue({
el: '#app',
vuetify: new Vuetify(),
})
setTimeout(()=>console.clear(), 100)
#app {
background: linear-gradient(to right, rgba(226,226,226,1) 0%, rgba(254,254,254,1) 100%);
}
.cardColor {
background-color: rgba(255, 255, 255, 0.5) !important;
border-color: white !important;
}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@3.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
<div id="app">
<v-app>
<v-content>
<v-container>
<v-card class="cardColor">
<v-card-text>
TEXT
</v-card-text>
<v-card-actions>
<v-btn color="primary" @click="foo">Button</v-btn>
</v-card-actions>
</v-card>
</v-container>
</v-content>
</v-app>
</div>
答案 1 :(得分:1)
您可以使用带有轮廓的颜色属性
<v-card outlined color="transparent">
...
</v-card>
答案 2 :(得分:0)
在CSS中,我们可以通过以下样式实现它:
.cardColor
{
z-index: 1;
position: relative;
width: 100%;
float: left;
}
.cardColor:before
{
position: absolute;
content: "";
display: block;
width: 100%;
height: 100%;
background: #fff;
opacity: 0.35;
top: 0;
left: 0;
z-index: -1;
}