Beispiel:CSS3 background-size.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html lang="de">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css">
	<title>background-size</title>
<style>
.contain { background-size: contain; }
.cover { background-size: cover; }
.eins  { background-size: 50px;}
.zwei  { background-size: auto 100px;}
.drei  { background-size: 50%; }
.vier  { background-size: 50% 100%; }		

figure {
	background-color: gray;
	background-image: url("https://wiki.selfhtml.org/mediawiki/images/9/9e/Talbruecke_poehl.jpg");
	background-position: center;
	background-repeat: no-repeat;
	border: thin solid;
	display: inline-block;
	height: 12em;
	margin: 1em 1em 0;
	text-align: center;
	width: clamp(18em, 45%, 35em); 
}
figcaption {
	background: white;
	border: thin solid;
	display: inline-block;
	margin-top: 10.5em;
	padding: 0 .5em;
}
		</style>
</head>
<body>
	<h1>Hintergrundbilder mit <code>background-size</code>  skalieren</h1>
	<figure class="contain"><figcaption>contain</figcaption></figure>
	<figure class="cover"><figcaption>cover</figcaption></figure>
	<hr>
	<figure class="eins"><figcaption>50px</figcaption></figure>
	<figure class="zwei"><figcaption>auto 100px</figcaption></figure>
	<figure class="drei"><figcaption>50%</figcaption></figure>
	<figure class="vier"><figcaption>50% 100%</figcaption></figure>

</body>
</html>