2012-08-09 123 views
1

我目前正在使用我喜歡放置在我的標題部分背景中的橫幅。我遇到的問題是圖像重複出現。我嘗試使用屬性no-repeat,結果我沒有得到任何東西顯示。該圖像被設置爲#header div的背景。我如何讓圖像不重複出現?背景div圖像 - 重複問題

CSS

<style> 
#header { 
    height:165px; 
    border-top:15px solid #000; 
    background-image: url(http://webprolearner2346.zxq.net/css-test2/images/banner1.png); 
} 
</stle> 

HTML

<div id="header"> 
     <div class="search"><input type="text" class="search-input" name="search" value="Search" onclick="$(this).val('');" /><input type="submit" class="search-submit" /></div> 
     <div id="navigation"> 

     <ul class="button-list"> 
     <h2>MAIN TITLE PAGE</h2> 
     <li><a href="#" class="buttonNav" >Content 1</a></li> 
     <li><a href="#" class="buttonNav" >Content 2</a></li> 
     <li><a href="#" class="buttonNav" >Content 3</a></li> 
     <li><a href="#" class="buttonNav" >Content 4</a></li> 
     <li><a href="#" class="buttonNav" >Content 5</a></li> 
     </ul> 
     </div> 
    </div> 
+0

「無重複」在哪裏? – ChiefTwoPencils 2012-08-09 10:14:37

+1

'background-repeat:no-repeat;' – krish 2012-08-09 10:14:53

回答

3
#header { 
    height:165px; 
    border-top:15px solid #000; 
    background-image: url('http://webprolearner2346.zxq.net/css-test2/images/banner1.png'); 
    background-repeat: no-repeat; 
} 

證明:http://awesomescreenshot.com/029cplk1d

,但你不妨做這樣說:

background: url('http://webprolearner2346.zxq.net/css-test2/images/banner1.png') no-repeat; 
0

u能打通這個您想要的結果: -

#header { 
     background-image: url("http://webprolearner2346.zxq.net/css-test2/images/banner1.png"); 
     background-repeat: no-repeat; 
     border-top: 15px solid #000000; 
     height: 165px; 
    } 
0

你也可以試試這個;

<style> 
#header { 
    height:165px; 
    border-top:15px solid #000; 
    background:url(http://webprolearner2346.zxq.net/css-test2/images/banner1.png) no-repeat; 
} 
</style>