<h4>Властивість <code>background-size</code></h4>

<div class="demo">
	<div class="block cover"><span>cover</span></div>
	<div class="block contain"><span>contain</span></div>
	<div class="block auto"><span>auto</span></div>
</div>
* {
	box-sizing: border-box;
}
	
body {
	font-family: sans-serif;
	line-height: 1.45;
	font-size: 18px;
	padding: 16px 16px 0 16px;
	text-align: center;
}

h4 {
	color: #4f4f4f;
	font-weight: 400;
}

.demo {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.block {
	background: url(https://lorempixel.com/250/50/);
	background-repeat: no-repeat;
	width: 150px;
	height: 150px;
	border: 4px solid #4f4f4f;
	margin-top: 56px;
}

.block > span {
	position: relative;
	top: -55px;
	font-family: monospace;
	font-size: .8em;
	color: #4f4f4f;
}

.cover { background-size: cover; }
.contain { background-size: contain; }
.auto { background-size: auto; }

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.