Ephraim
Ephraim

Reputation: 8401

Getting the dimensions of an element with SCSS?

I recently discovered scss, and the fact that it has the ability to use mathematical operators. What I am wondering is: **Is there a way for me to dynamically retrieve the dimensions of an element to use for setting the dimensions of a different element?

An example of what I would like to do is as follows (written in jQuery):

$("#myparagraph").height($("#page").height() / 6);

Is there any way to do this using scss?

Upvotes: 14

Views: 16977

Answers (1)

Jason
Jason

Reputation: 52527

No.

While SCSS will allow you to calculate values using variables and math, it still compiles down to CSS. CSS is not a dynamic language that can provide calculated dimensions on DOM objects. It is also not queryable. SCSS is not a separate language in and of itself, but rather a pre-processor that allows you to more efficiently create CSS. Therefore, anything that you can do in SCSS you can do in plain CSS and vice versa (although it may be more difficult to keep track of) and nothing more or less.

Upvotes: 27

Related Questions