Skip to content

Instantly share code, notes, and snippets.

@tylergaw
Created August 25, 2012 18:45
Show Gist options
  • Save tylergaw/3469117 to your computer and use it in GitHub Desktop.
Save tylergaw/3469117 to your computer and use it in GitHub Desktop.
Flexible background image and height with vw
/**
* Flexible background image and height with vw
*/
div {
background: transparent url("https://www.djangoproject.com/m/img/logos/django-logo-positive.png") no-repeat center top;
background-size: 90%;
height: 28vw;
width: 90%;
}
<div></div>
<p>
Content that should come after the image. Usually you'd need to do some trickery with the div.
My normal method is to put a percentage padding-top on it. I've never found a formula for what
percentage works, I just tinker around with it until it works. This feels much better.
</p>
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment