Skip to content

Instantly share code, notes, and snippets.

@kulicuu
Last active July 26, 2016 15:15
Show Gist options
  • Select an option

  • Save kulicuu/28dabc2ae1ce1de3867ddbfeaa2d2749 to your computer and use it in GitHub Desktop.

Select an option

Save kulicuu/28dabc2ae1ce1de3867ddbfeaa2d2749 to your computer and use it in GitHub Desktop.
centering an image that is absolutely positioned with respect to containers that are fixed percentage of screen width
# say we have width given ; screen width
width = 360
image_size = .222222 * width
container_size = .33333333333 * width
#the amount to shift left
left_var = (.5 * container_size) - (.5 * image_size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment