Search code examples
csspositioningfixed

CSS - positioning in % and px combine


Is there any way to set a div like that:

right: 50% - 450px;

I need it to be compatible for all resolutions. It's a fixed div, and i need it to be in the center + 450px to the right. anyone have a suggestion?

Hope you understand what I mean.


Solution

  • used to this Calc()

    calc() is a native CSS way to do simple math right in CSS as a replacement for any length value (or pretty much any number value). It has four simple math operators: add (+), subtract (-), multiply (*), and divide (/). Being able to do math in code is nice and a welcome addition to a language that is fairly number heavy.

    right: calc(50% - 450px);
    

    more info