I'm looking for a way in css to select any element with a class that matches the beginning of a string. I know about the [class*="string"] and [class^="string"] rules, but those aren't exactly what I'm looking for. ^= only matches the first class, so any preceding classes will break it. And *= looks for any part of the string, not just the beginning.
http://codepen.io/anon/pen/HiJjL
HTML:
<div class="asdf col-6">match</div>
<div class="col-6">match</div>
<div class="x-col-6">dont match</div>
CSS:
[class *= "col-"] {
color:red;
}
[class ^= "col-"] {
font-weight:bold;
}
The pen illustrates the problem. The first selector is too broad, the second is too narrow. Of course I can work around this by using *= and being careful with my other class names, but I was curious if this is possible.