I am trying to solve a bug in CKEditor where it doesn't apply the margin properly. Using Bootstrap, the first span's margin is effectively ignored as it falls outside the row. However in CKEditor, for some reason it sits inside the row, thus pushing the last span onto a new line as there isn't enough room inside the row.
A simple way to solve this is to just set the margin-left for the first span to 0, and so I ended up adding this to my content.css file:
[class*="span"]:first-of-type {
margin-left: 0px;
}
And this works nicely, as long as all the spans are the same, all divs or all articles. But if I have an article and an aside, then the css appears to pick them up as two different first type's, and applies the :first-of-type
rule to both of them. For example:
<div class="container">
<div class="row">
<article class="span6">
...some html text
</article>
<aside class="offset3 span3">
...some more html text
</aside>
</div>
</div>
Both the article and the aside will have had their margin-left set to 0, when I only want the article's margin-left set to 0. This is just an example, there could be any combination possible of divs, articles and asides you could think of, as well as any number that bootstrap allows.
After a short Google I found this question, which seemed similar to my problem. The answer explained that the :first-of-type
actually works off the element, not the class, which explains the behavior I saw. Unfortunately the work around specified in that answer can't work for me as I'm trying to remove some css from the first div, and leave the rest intact.
Is there any workaround I could use that would allow me to target the first element with [class*="span"]
? Failing that is there any other known solution to this bug with CKEditor and Bootstrap?