Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use `&` and a tag on the same selector

I am trying to write a nested selector that selects a certain tag that has a certain attribute, for example

<li foo="bar">

To select this, li[foo="bar"] would work, but I want to nest it under [foo="bar"] using the scss & notation because I have other things with the [foo="bar"] attribute (e.g., <div foo="bar" class="baz">), and I want to group them together. When I try:

[foo = "bar"]{
  &li{
    ...
  }
  &.baz{
    ...
  }
}

It returns an error that says li may only be used at the beginning of a compound selector, and if I try:

[foo = "bar"]{
  li&{
    ...
  }
  &.baz{
    ...
  }
}

then it says & may only be used at the beginning of a compound selector. How can I do this correctly?

like image 716
sawa Avatar asked Feb 02 '14 14:02

sawa


People also ask

How do we use a semicolon?

Use a semicolon to replace a period between related sentences when the second sentence starts with either a conjunctive adverb or a transitional expression, such as for example, for instance, that is, besides, accordingly, furthermore, otherwise, however, thus, therefore.

When should a semicolon be used examples?

A semicolon may be used between independent clauses joined by a connector, such as and, but, or, nor, etc., when one or more commas appear in the first clause. Example: When I finish here, and I will soon, I'll be glad to help you; and that is a promise I will keep.

How do you use commas and semicolons?

When a comma separates two complete sentences joined by a conjunction (and, but, or, nor, for, so, or yet) the comma and the conjunction can be replaced with a semicolon. I ate dinner, and I went to the movies. = I ate dinner; I went to the movies. She finished top of her class, but she was struggling to find work.

How do you use a colon example?

Connecting two related sentences A colon can be used to connect two independent sentences. Typically, a colon is used when the second sentence clarifies or explains the first sentence. For example, Me and my sisters are really excited: We're going to Disneyland!


1 Answers

The right syntax nowadays would be li#{&}.

like image 174
cdauth Avatar answered Oct 02 '22 20:10

cdauth