Search code examples
cssdimension

Calculate a margin using CSS percentage and unit together


margin-left: 100 + 20%;

I want to do something the same as above. But CSS does not have any format. How can I successfully use these together ?


Solution

  • Without javascript? Only by wrapping that content into another element (usually <div>) and splitting that margin to two elements.

    Something like:

    <div style="margin-left:20%">
      <div style="margin-left:100px">
      <!-- content -->
      </div>
    </div>