2017-01-09 77 views
2

我把背景图像在我的离子头内的图像,但图像似乎被放大大小离子头

enter image description here

在它是因为它的第一个图像是在第二,因为我想它是

.background-header { 
    background: url(../img/bg_header_menu.png) !important; 
    background-size: cover; 
} 

我试过背景大小:盖,100%和一些更多的东西,但没有成功

感谢

编辑与HTML:

<ion-header-bar class="background-header"> 
</ion-header-bar> 

对不起,我可怜的解释,什么情况是,第一形象似乎被放大。这样笔画在第二个图像中看起来不一样。

和影像尺寸为1366x177,这不是一个重复的图像

+0

看起来所有的背景属性? –

+0

好。这一切都取决于html结构。你能分享一下吗? 。 (HTML代表'.background-header'和任何可能相关的东西) –

+0

也做片段。 – Rahul

回答

2

好。使用

background: url(../img/bg_header_menu.png) !important;将让所有的默认背景的属性是重要的(图像,位置,重复,附件等),所以你写了,接下来的事情,background-size:cover,是因为以前的重要

你应该使用空background-image:url(../img/bg_header_menu.png)代替background

见下文片断例如:

.background-header { 
 
    background-image: url(http://placehold.it/1366x177) ; 
 
    background-size: cover; 
 
    background-repeat:no-repeat; 
 
    background-position:center center; 
 
    width:100%; 
 
    height:177px; 
 
    float:left; 
 

 
}
<ion-header-bar class="background-header"> 
 

 
</ion-header-bar>

或者您也可以使用

background:{url(http://placehold.it/1366x177) no-repeat scroll center center /cover transparent } 

如果你想要像你想摆脱切换按钮来使用一种风格

+0

谢谢!这解决了我的问题。谢谢大家 –