P粉4821083102023-08-27 10:46:27
If I understand the question correctly, you want to override the styles of some Flickity.vue
components in the parent component.
With Scoped CSS (i.e. <style scoped>
), styles are only applied to the current component and not its child components. If you want to continue using Scoped CSS, you can use :deep()
(::v-deep
in Vue 2) around the selector to target dynamic child components, As follows.
Since the Flickity.vue
component itself has higher CSS specificity for .carousel-cell
's scoped styles, the parent component needs to increase its specificity (e.g., using !important
).
<style scoped> :deep(.carousel-cell) { background-color: red !important; width: 300px !important; height: 160px !important; margin-right: 10px !important; } /* position dots in carousel */ :deep(.flickity-page-dots) { bottom: 0px; } /* white circles */ :deep(.flickity-page-dots .dot) { width: 12px; height: 12px; opacity: 1; background: blue; border: 2px solid white; } </style>
Alternatively, you can use a normal/non-scoped <style>
block. Just remove the scoped
attribute.