I have a Bootstrap Vue ProgressBar. I need to add to the class ".progress-bar" pseudo element :: after with content icon (from FontAwsome). And I also want it to be dynamic. Because I have implemented steps in my ProgressBar(from 0 tp 100) and i want, when i click, this icon will go with ProgressBar line.
<b-progress v-bind:style="styleProgressBar" :value="counter" :max="max"></b-progress>
export default {
components:{
'navbar':navbar
},
name: "myPage",
data() {
return {
counter: 0,
max: 100,
step:1,
}
},
methods:{
prev() {
this.step--;
},
next() {
this.step++;
if (this.counter < 100) {
this.counter += 34;
}
}
}
}
I also saw this: https://v2.vuejs.org/v2/guide/class-and-style.html
<div v-bind:style="styleObject"></div>
data: {
styleObject: {
color: 'red',
fontSize: '13px'
}
}
Let's say you have a parent component:
<div id="parent">
<ChildComponent id="child"> // Possibly from another library?
</div>
// renders ->
<div id="parent">
<div id="child">
<div id="child-component-item">
::after
</div>
</div>
</div>
The challenge is creating a binding for the #child-component-item:after
selector.
We can use css vars to solve this problem, by "reaching into" the child component with some CSS. Note that you may have to use ::v-deep
if your style is scoped
.
parent-component.js
<div id="parent-component" :style="{'--bgColor': bgColor}">
<ChildComponent>
</div>
<script>
export default {
data() {
return {
bgColor: 'red'
}
}
}
</script>
<style>
#child-component-item:after {
background-color: var(--bgColor)
}
</style>
Use css var()
And then :style="{ '--varName': xxx}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With