1

I'm new to LESS. Is there a way to get the parent height and width? I'm trying to set something to be a percentage of the parent. For instance:

fictitious pseudo code because I have no idea what I'm doing

@myheight: parent.height / 4;
@mywidth: parent.width / 4;

.myRelObject {
    height: @myheight
    width: @mywidth
}

The closest I found was this SO question, so if someone can just tell me if/how to get parent height/width I can probably get it from there.

Community
  • 1
  • 1

1 Answers1

1

You don't need LESS for this

.myRelObject {
    height: 25%;
    width: 25%;
}

edit: I should be more specific, unless the parents have a set height and width you can't get that value until it is rendered in the DOM, so it is better to use vanilla CSS like above.

chris vdp
  • 2,842
  • 2
  • 22
  • 35