Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<title>CSS Test: Background Intrinsic Sizes: Intrinsic Percentage Width and Height</title>
<link rel="author" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact"/>
<link rel="match" href="background-intrinsic-ref.xht"/>
<meta name="flags" content="svg" />
<meta name="assert" content="A background image with only an intrinsic ratio
covers largest rectangle at that ratio that exceeds neither the height nor
width of the background positioning area." />
<style type="text/css">
/* Setup. Use 5:6 ratio because it's weird and unlikely to be hard-coded anywhere. */
div {
position: relative;
}
.cover, .limit {
width: 120px;
height: 120px;
margin: 0.5em;
background: green; /* Used to match reference; remove for debugging. */
}
.control {
position: absolute;
top: 10px; bottom: 10px;
left: 10px; right: 30px;
}
.cover .control {
background: red;
}
.limit .control {
background: green;
}
.test {
/* 80x100 bgpos area */
height: 80px;
width: 60px;
padding: 10px;
border: 10px solid transparent;
}
/* Test */
.cover .test {
background: no-repeat url(support/green-intrinsic-width-pc-height-pc.svg);
}
.limit .test {
background: no-repeat url(support/red-intrinsic-width-pc-height-pc.svg);
}
.control {
width: 32px;
height: 60px;
}
</style>
</head>
<body>
<p>There must be two green boxes below and no red.</p>
<div class="cover">
<div class="control"></div>
<div class="test"></div>
</div>
<div class="limit">
<div class="test"></div>
<div class="control"></div>
</div>
</body>
</html>