Complete the code to bind the background color dynamically using inline styles.
<script> let bgColor = 'lightblue'; </script> <div style="background-color: [1]"> This box has a dynamic background color. </div>
The variable bgColor holds the color value. Using it directly inside the style attribute applies the dynamic color.
Complete the code to set the font size dynamically using inline styles.
<script> let fontSize = 20; </script> <p style="font-size: [1] + 'px'"> This text has dynamic font size. </p>
The variable fontSize holds the numeric size. Concatenating it with 'px' sets the font size in pixels.
Fix the error in the code to apply dynamic color style correctly.
<script> let textColor = 'red'; </script> <h1 style="color: '[1]'"> Dynamic colored heading </h1>
Remove the quotes around the variable inside the style attribute. Use {textColor} to insert the variable value dynamically.
Fill both blanks to create a dynamic style object and apply it inline.
<script> let size = 18; let color = 'green'; let styleObj = { [1]: size + 'px', [2]: color }; </script> <p style="[1]: {styleObj[[1]]}; [2]: {styleObj[[2]]}"> Styled with dynamic object </p>
The style object keys must be CSS property names as strings. Use font-size and color to set font size and text color dynamically.
Fill all three blanks to bind multiple dynamic styles inline using Svelte syntax.
<script> let width = 100; let height = 50; let bg = 'yellow'; </script> <div style="width: [1] + 'px'; height: [2] + 'px'; background-color: [3];"> Box with dynamic size and color </div>
Use the variables width, height, and bg to set the box's width, height, and background color dynamically.