Skip to content

Instantly share code, notes, and snippets.

@surfjedi
Last active August 29, 2015 14:22
Show Gist options
  • Save surfjedi/833bd47e0718e11d7eb7 to your computer and use it in GitHub Desktop.
Save surfjedi/833bd47e0718e11d7eb7 to your computer and use it in GitHub Desktop.
css background-size property demo
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<style>
#wrapper {
width:56%;
max-height: 100%;
background: red;
}
figure {
background-size: contain;
background-repeat: no-repeat;
background-color: black;
background-position: center;
min-height: 200px;
}
</style>
</head>
<body>
<div id="wrapper">
<figure style="background-image: url(http://placehold.it/350x150)"></figure>
<figure style="background-image: url(http://placehold.it/850x150)"></figure>
<figure style="background-image: url(http://placehold.it/50x550)"></figure>
</div>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->
<p>Hello world! This is a css-background-image demo</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment