Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember handlebars and adjacent CSS selector

Ember Handlebars is messing with adjacent sibling CSS selectors (el + el)

For example, I have list of items:

{{#each item in items}}                    
  <span class="item">{{item}}</span>
{{/each}}

And I want to add spacing between them with this rule:

.item + .item {
  margin-left: 1em;
} 

But it doesn't work, because Ember is inserting Metamorph placeholders between items (tags like <script id="metamorph-1-end" type="text/x-placeholder"></script>)

What should I use instead of adjacent sibling selector with handlebars?

like image 613
Valentin Nemcev Avatar asked Jun 04 '26 04:06

Valentin Nemcev


1 Answers

Use general sibling (or next sibling) selector (el ~ el).

Like this:

.item ~ .item {
  margin-left: 1em;
} 

It will 'skip' Metamorph placeholder tags and any other tags between items.

like image 120
Valentin Nemcev Avatar answered Jun 05 '26 17:06

Valentin Nemcev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!