Shorten name

pull/7161/head
gtm-nayan 5 years ago committed by Nayan Gautam
parent 0f76a93863
commit e0867166c2

@ -1,9 +1,9 @@
<script>
let backgroundOpacity = 0.5;
$: color = backgroundOpacity < 0.6 ? '#000' : '#fff';
let bgOpacity = 0.5;
$: color = bgOpacity < 0.6 ? '#000' : '#fff';
</script>
<input type="range" min="0" max="1" step="0.1" bind:value={backgroundOpacity} />
<input type="range" min="0" max="1" step="0.1" bind:value={bgOpacity} />
<p>This is a paragraph.</p>

@ -1,11 +1,11 @@
<script>
let backgroundOpacity = 0.5;
$: color = backgroundOpacity < 0.6 ? '#000' : '#fff';
let bgOpacity = 0.5;
$: color = bgOpacity < 0.6 ? '#000' : '#fff';
</script>
<input type="range" min="0" max="1" step="0.1" bind:value={backgroundOpacity} />
<input type="range" min="0" max="1" step="0.1" bind:value={bgOpacity} />
<p style:color style:--o={backgroundOpacity}>This is a paragraph.</p>
<p style:color style:--o={bgOpacity}>This is a paragraph.</p>
<style>
p {

@ -5,7 +5,7 @@ title: Inline styles and the style directive
Apart from adding styles inside style tags, you can also add styles to individual elements using the style attribute. Usually you will want to do styling through CSS, but this can come in handy for dynamic styles, especially when combined with CSS custom properties.
Add the following style attribute to the paragraph element:
`style="color: {color}; --o: {backgroundOpacity};"`
`style="color: {color}; --o: {bgOpacity};"`
Great, now you can style the paragraph using variables that can change based on your input and you don't have to make a class for every possible value.
@ -14,7 +14,7 @@ This can however get unwieldly if you have to write a rather long string, and mi
```html
<p
style:color
style:--o={backgroundOpacity}
style:--o={bgOpacity}
>
```

Loading…
Cancel
Save