how to pass html number to css

56

.c {color:  var(--c)}
.m {margin: var(--m)}
<div id="div1" class="divs" style="--bg: #ff6; --pad: 1;">div1</div>
<div id="div2" class="divs" style="--bg: #f66; --pad: 2;">div2</div>
.divs {
  background: var(--bg);
  padding: calc(var(--pad)*5px);
}
<div class="c" style="--c: blue" >Foo</div>
<div class="m" style="--m: 0 2em">Bar</div>
<div class="c" style="--c: green">Baz</div>

Comments

Submit
0 Comments