Search code examples
percentagesasspixel

Subtract Pixels From Percentage in SASS?


I know you're able to do some simple math in Sass/Scss. But is there a way to subtract pixels from percentages? For example:

$image-size: 200px;

.bio {
    width: 100% - $image-size;
}

Solution

  • I don't see how that would even work, fact is SASS can't magically know the size your box will have.

    Now if I get what you're trying to do, best solution would be to wrap .box's parent width into a variable and then substract your image width to that variable - considering 100% width means it will get 100% of a certain width.