From the course: Learning Vue.js

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Binding style attributes

Binding style attributes - Vue.js Tutorial

From the course: Learning Vue.js

Start my 1-month free trial

Binding style attributes

- [Instructor] In this video, we'll take a look at how we can use dynamic style attributes in view. Whether we're using view or just writing static HTML. The use of style attributes is generally something we should avoid because it has a tendency to litter our markup with CSS properties that would be better off in an external style sheet but there are exceptions to that rule of thumb. And also it can sometimes be helpful for quick prototyping. A classic example for a dynamic style attribute is wanting to change a numeric value at a very granular level, such as a font size or a width which would be difficult to set up with CSS classes. Let's see if we can add an option to dynamically change the font size on our card manager page. So first I'm going to wrap this repeating div in another div where we'll be adding the dynamic style attribute. And that's just so that I'm not repeating it over and over again in the card pair div…

Contents