Vue Style Binding
Data-driven styling is a very powerful feature of Vue. We can use the v-bind directive (usually abbreviated as :) to dynamically manipulate an element's class and inline style.
Binding HTML Class
We can pass an object to :class to dynamically toggle classes.
Object Syntax
Array Syntax
We can also pass an array to :class to apply a list of classes:
Binding Inline Style
We can use :style to bind inline CSS styles.
Object Syntax
The object syntax for :style is very intuitive—it looks almost like CSS, but it's actually a JavaScript object. CSS property names can be written in camelCase or kebab-case.
Array Syntax
We can also bind an array containing multiple style objects to :style. These objects will be merged and applied to the element.
Automatic Prefixing
When you use a CSS property in :style that requires a browser engine prefix, such as transform, Vue will automatically detect and add the corresponding prefix. Vue checks for supported properties at runtime, and if the current browser doesn't support a certain property, Vue will test various prefixed variants. For example, flex will automatically attempt to add -webkit-flex and -ms-flex prefixes.