#Is it possible to use JavaScript variables inside <style> tags?

3 messages · Page 1 of 1 (latest)

fresh wagon
#

Hi there!
I'm just getting started with Astro by creating a simple blog. I was just wondering if it's possible to use information coming from the Astro component (the JavaScript part) inside style tags within that same component. What I'd like to do is use the heroImage from one of the sample blog posts as a background image for the blog card, with some transparency. This is the type of thing that is much easier to do with CSS since I can just specify the image itself and "cover" to expand it to take up whatever amount of space it needs to. I might use it for some other things, but I'd like to know if it's possible before I go down the rabbit hole 😄

Thanks!

ocean quest
fresh wagon
#

Ah, nice. That looks like what I'm look for, thank you!