Search code examples
cssaspect-ratio

How would I calculate two given pixels to obtain its aspect ratio?


I've looked online on how to get the aspect ratio to write proper media queries for a website I'm trying to make but some of these numbers don't make sense.

What I'm trying to do is take two pixels, say, 667 x 325. I put those two numbers inside the website below, but result I'm getting is 667 : 325. I don't think that's correct, or is it?

https://aspectratiocalculator.com/

I've also tried looking for a mathematical formula to get these so I can just manually do these but there are so many out there that don't fit into the context of what I'm trying to obtain.

How can I get the aspect ratio of two given pixels?


Solution

  • Aspect ratio is width / height, e.g. 600 by 800 = 600/800 = 0.75.

    The calculator is correct because the "Ratio" by conventional meaning of the word is 600:800 or 0.75:1 or 0.75 (as we programmers use it)