這是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規則來實現很容易「背景大小:蓋|包含」。 –