You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/documentation/tutorial/13-advanced-styling/04-style-directive/app-b/App.svelte

16 lines
346 B

<script>
let bgOpacity = 0.5;
$: color = bgOpacity < 0.6 ? '#000' : '#fff';
</script>
<input type="range" min="0" max="1" step="0.1" bind:value={bgOpacity} />
<p style:color style:--opacity={bgOpacity}>This is a paragraph.</p>
<style>
p {
font-family: 'Comic Sans MS', cursive;
background: rgba(255, 62, 0, var(--opacity));
}
</style>