Target an HTML element from code, to change Style properties

Those are just some variables I’m storing values in. This example is showing you how to change the CSS attributes of your HTML template using Python only

Here’s a hint: lets say the element that you’re trying to change is called .anvil-root-container. Colour and transparency are two separate attributes in CSS, I’ve already shown you show to change the colour with document.getElementById('anvil-root-container').style.background, which needs to be a hex colour code, formatted as a str, you can try using print(dir(document.getElementById('anvil-root-container').style)) to help you try and find the attribute related to transparency

1 Like