ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

css background-size: cover not working when navigating

Open mobilabgit opened this issue 12 years ago • 6 comments

I am using today's bleeding edge just from master release of ionic. I noticed that my background image resizes incorrectly.

I have two ion-views both with a css class that sets the following:

background: url("img/voetbalveld.png") no-repeat center center fixed; -webkit-background-size: cover!important; background-size: cover!important; When I open the app and see the first view, the background looks good. However, when I navigate to the second view

the background-size cover doesn't work and instead I see only a part of the image as if zoomed in (the image is too large to show in the screen)

mobilabgit avatar Dec 03 '14 20:12 mobilabgit

This sounds exactly what background-size: cover; is meant to do, no?

Do you want the background image to be as large as possible while showing the image? Or do you want to always cover the full background, even if it means part of the image may not be shown?

It sounds like it could be a problem with the custom CSS, can you provide a codepen example?

drewrygh avatar Dec 03 '14 23:12 drewrygh

Hi,

I want the image to cover the full background, even if it means part of the image may not be shown. I have an image that is larger than the viewport, but I still want it to be shown as much as possible with respect of ratio.

In this codepen you can see a large image being correctly shown with the cover property: http://codepen.io/anon/pen/raObpO

When you turn of the cover property you see what I am seeing when I navigate to my second page on my iOS 6.1.6 (iphone3). The image is shown as is (and thus looked zoomed in because it is too large for the screen).

mobilabgit avatar Dec 04 '14 10:12 mobilabgit

btw when I want to have a look at the css inside web inspector on safari, the background image 'jumps' to the correct size (it uses the cover property) when I click on the view element.

mobilabgit avatar Dec 04 '14 10:12 mobilabgit

Also, at the moment of the page transition I see that both the background of the first page and the second page (that during transition moves on top of the first) both get incorrect backgrounds. When I move back to the first page, the background is always shown correctly again.

mobilabgit avatar Dec 04 '14 10:12 mobilabgit

Greetings, @mobilabgit!

My sensors indicate that you have created an issue on our tracker that is more asking for usage help than an actual error with Ionic framework.

This Github issue tracker is used to track features, problems, and development of the framework.

If you wish to get help using the framework itself, the recommended place is the forum.

Thank you for allowing me to assist you.

Ionitron avatar Dec 05 '14 20:12 Ionitron

+1

beauby avatar Mar 31 '15 11:03 beauby