5 ms·
For anyone experimenting with inline styles, there are a couple of things you'll still need a stylesheet for. Inline styles can't modify psuedo-elements or psu
by dwwoelfel 11y ago
For anyone experimenting with inline styles, there are a couple of things you'll still need a stylesheet for.
Inline styles can't modify psuedo-elements or psuedo-styles. You'll need to define styles for :before, :focus, :active, etc. in a stylesheet. These selectors are really important if you want to make appealing forms, e.g. http://blog.circleci.com/adaptive-placeholders/ http://blog.circleci.com/adaptive-placeholders/
Vendor prefixes are difficult to do with inline styles. If you're using a map to represent your styles, you can't define multiple values for the same key. For example, if you wanted to use flexbox, you'd need "display: flex" and "display: -webkit-flex". Solving that with inline styles is going to get messy. It's much easier to use less's auto-prefixer plugin to do that for you.
You need a stylesheet to define keyframe animations.
There's probably more I've missed, but those were the problems I ran into when I experimented with inline styles. In the end, the vender prefixes problem made me move all of my styles to a stylesheet. The good news is that the problem could probably be solved by applying a runtime equivalent of less's auto-prefixer.
- danr4 11y agoGood point. This is why I think there is a place for a hybrid of javascript styles which are processed by build tools to generate style sheets. https://github.com/teal-lang https://github.com/teal-lang is an interesting approach
- snookca 11y agoWhile you can't modify pseudo elements or pseudo classes, you can replicate them using actual elements and conditional logic. I've seen React examples that do just that.