Skip to content

Parent selector not working #211

Open

Description

@RedHatter

When I use the code below #thing get a width of 0.

#content {
  width: == 800;
  #thing {
    width: == ^[width];
  }
}

But when I reference #content directly #thing gets a width of 800 as expected.

#content {
  width: == 800;
  #thing {
    width: == ($ #content)[width];
  }
}

What am I missing? Why doesn't the first code work?

Activity

  1. changed the title [-]Constraint works as standalone but not in ruleset,[/-] [+]Parent selector not working[/+] on Jun 28, 2016
  2. gabeblackbeard commented on Jul 28, 2016

    @gabeblackbeard

    Hey there. I figure you probably found a way around this issue by now, but I'll leave here the solution I've found nonetheless, as maybe it will help others.

    For some reason, if you are writing your code inside a separate file that is linked by the html page, your whole nesting must be done inside a "body" selector. Like this:

    body {
        #parent-div {
            width: == 800;
            #child-div{
               width: == ^width;
            }
        }
    }
    

    If you do it like that, child-div's width will successfully refer to parent-div's width. Otherwise it seems it will refer to (I believe) the document's width.

    If your code is in a style tag in the head of the html page, however, no "body" selector is necessary; your code would have worked as is.

    I have no idea what causes this behavior, but there it is. Maybe someone will shed a better light on why it works like that.

  3. Inviz commented on Jul 30, 2016

    @Inviz
    Contributor

    Try more up to date version from master.

  4. H-s-O commented on Nov 11, 2016

    @H-s-O

    Thanks @gabeblackbeard for the body selector tip !

    If anyone of the GSS team is listening, this needs to be adressed in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions