I'd like to store the current value of a property for later use. It's already been solved for jQuery.
The issue is that I'm using a @mixin
to apply a CSS hack in several places (Justified Block List) and I'd like to restore the font-size
property in .block-list *
(currently all text in sub-elements is just collapsed).
Unsatisfactory workarounds:
@mixin
on @import
. This is of course in the general case not the same font size as the objects which the mixin is applied to.@include
the typography stylesheet in several otherwise unrelated files.Possibly satisfactory workarounds:
So, it is possible to use Sass with CSS custom properties. In fact, this would be the recommended route to follow since it would allow a smooth JavaScript-CSS interaction. The only downside to this approach is it does not work with discontinued or outdated browser versions that don't support CSS custom properties.
The used value of a CSS property is its value after all calculations have been performed on the computed value. After the user agent has finished its calculations, every CSS property has a used value. The used values of dimensions (e.g., width , line-height ) are in pixels.
Sass variables are all compiled away by Sass. CSS variables are included in the CSS output. CSS variables can have different values for different elements, but Sass variables only have one value at a time.
SASS (Syntactically Awesome Style Sheets) is a pre-processor scripting language that will be compiled or interpreted into CSS. SassScript is itself a scripting language whereas SCSS is the main syntax for the SASS which builds on top of the existing CSS syntax.
There's no way to tell the computed value of a property until the styles are actually applied to a document (that's what jQuery examines). In the stylesheet languages, there's no "current" value except the initial value or the value you specify.
Save the font size whenever you change it, and pass that seems best, and @BeauSmith has given a good example. This variant lets you pass a size or fallback to a defined global:
=block-list($font-size: $base-font-size)
font-size: 0
> li
font-size: $font-size
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With