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/03-inline-styles/app-b/App.svelte

16 lines
354 B

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