[英]Vuetify JS - Apply CSS to a specific component
Let's say I have a Test.vue with 2 v-text-field components.假设我有一个带有 2 个 v-text-field 组件的 Test.vue。
I want to apply my CSS only to the first text field.我只想将我的 CSS 应用于第一个文本字段。
Test.vue测试.vue
<template>
<div class="test">
<v-text-field></v-text-field>
<v-text-field></v-text-field>
</div>
</template>
<script>
export default {};
</script>
<style scoped>
.v-text-field {
width: 100px;
}
.v-text-field >>> input {
font-size: 2em;
color: #fff;
}
.v-text-field--outlined >>> fieldset {
color: #000000 !important;
}
</style>>
How about to use the first-child CSS selector如何使用 first-child CSS 选择器
<style scoped>
.test:first-child {
width: 100px;
}
.test:first-child >>> input {
font-size: 2em;
color: #fff;
}
.test:first-child .v-text-field--outlined >>> fieldset {
color: #000000 !important;
}
</style>
There are a lot of ways to do this, but I think it would be best to simply give your specific text field an id and reference that.有很多方法可以做到这一点,但我认为最好简单地为您的特定文本字段提供一个 id 并引用它。
<div class="test">
<v-text-field id="my-text-field"></v-text-field>
<v-text-field></v-text-field>
</div>
#my-text-field {
//your styling
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.