6

This would bind background-color property to the <td> element.

    <td :style="{backgroundColor: (props.item.release_date ? 'green' : 'transparent' ) }">
Some text
</td>

But what if I want to bind NOT ONLY the backgound-color same time I want to bind the foreground color (Normal color property) as well.

How do I bind multiple style properties to an element?

2 Answers 2

14

First of all, there's no foreground color in css. You can use multiple style with comma separated key: value pairs like:

:style="{
   backgroundColor: (props.item.release_date ? 'green' : 'transparent' ), 
   color: 'red', 
   width: '120px' 
 }"
Sign up to request clarification or add additional context in comments.

Comments

2

I was in a situation where I couldn't put all the styles in one object so I found this alternate way of style binding in vue:

vue style binding, Object syntax

vue style binding, Array syntax

basically you can have multiple style object and pass them as array to the style attribute like this:

:style="[styleObjectOne, styleObjectTwo]"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.