Skip to content

Instantly share code, notes, and snippets.

@zordius
Created May 18, 2017 03:52
Show Gist options
  • Save zordius/2fb073d94d1535ce48ea0740cd91956f to your computer and use it in GitHub Desktop.
Save zordius/2fb073d94d1535ce48ea0740cd91956f to your computer and use it in GitHub Desktop.
1:1 image in react
<style>
.img:before {
display: block;
content: "";
width: 100%;
padding-top: 100%;
}
.img {
display
background-color: #f00;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
</style>
<div class={classnames(this.p style.img" style="background-image:url(https://s.yimg.com/wb/images/0B792B7504D98BB5E494D567FA957EE3859E3973)">{child}</div>
<Image img="Xxxx" />
<Image class img="xxxx">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment