Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Created October 22, 2019 10:16
Show Gist options
  • Select an option

  • Save dpaluy/745a155d742f6056cd4a1f926a1250c3 to your computer and use it in GitHub Desktop.

Select an option

Save dpaluy/745a155d742f6056cd4a1f926a1250c3 to your computer and use it in GitHub Desktop.
Calculate Responsive CSS with Ruby
s0 = 375.0; x0 = 14.0
s1 = 1920.0; x1 = 90.0
v = ((x0 - x1) * 100) / (s0 - s1)
p = x0 - ((s0 / 100) * v)
puts "calc(#{p.round(2)}px + #{v.round(2)}vw)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment