这是5月的HTML标记如何使背景图像的高度(或空跨度)响应?
<header>
<span> <!-- background image here --> </span>
<hgroup>
<h1 class="testing">CSS3 and Compass Documentation</h1>
<h2>here I am going to document my compass and CSS3 learning</h2>
</hgroup>
</header>
,这将是我的CSS的市场:一旦你开始做浏览器窗口小(iphone尺寸例如)
header span {
background: url(banner.gif) center 0 no-repeat;
background-size: 100% auto;
display: block;
height: 170px; /* maybe this is where it needs changing*/
width: 100%;
}
的问题开始。图像缩小(因为我希望它),但是仍然高度保持170px
离开图像之间和hgroup
内容
我曾尝试使用height: 100%
更大的差距,但这并不在所有的工作(在这种情况下,至少)。
如果你需要演示http://jsfiddle.net/Jcp6H/
感谢。但出于利益考虑,它是更多钞票,以“大小根据其背景图像上的元素...的高度” - 让我想要 – aurel
我不认为这是可能的大小基于它的背景图像尺寸的元素。周围的其他方法虽然(底座上的元件尺寸背景图像大小)今天可以用CSS规则来实现很容易“背景大小:盖|包含”。 –