This macro allows you to change a target element's styles.
| Author | ChapelR |
| Website | https://twinelab.net/custom-macros-for-sugarcube-2/#/css-macro |
| Story format | SugarCube 2 |
| Last checked | Mon Jul 22 2024 |
| License | Unlicense |
| Download | css.zip |
This macro allows you to change a target element's styles.
⚠️ DOM macro warning:
From the SugarCube docs:
All DOM macros require the elements to be manipulated to be on the page. As a consequence, you cannot use them directly within a passage to modify elements within said passage, since the elements they are targeting are still rendering and not yet on the page. You must, generally, use them with a interactive macro (e.g.
<<link>>) or within thePassageDonespecial passage. Elements which are already part of the page, on the other hand, present no issues.
Demo Twee code:
:: Start
<<button 'Change Style'>>
<<css '#hello' 'text-decoration' 'underline' 'text-transform' 'uppercase' 'font-size' '1.2rem'>>
<</button>> @@#hello;Hi there!@@