I have the following HTML code:
<p class="message">
Hi there
<span class="emoji-native"></span>
this is cool!
<span class="emoji-native"></span>
<span class="emoji-native"></span>
<p>
I want to add a margin: 0 3px;
for all .emoji-native
nodes and I also want to set margin-left: 0px
for immediate next .emoji-native
node.
This is the CSS code I have:
.emoji-native {
margin: 0 3px;
}
.emoji-native + .emoji-native {
margin-left: 0px;
}
It works well when I have multiple emojis next to each other (exactly what I want), but, if I have text between emojis, it will also affect the last emoji, meaning the +
operator does not count :text
elements as nodes and just ignores them.
Is there a way to do this without wrapping the text contents into another <span>
tag?
Thanks.