最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Ionic How to keep fixed background while browsing the views - Stack Overflow

programmeradmin4浏览0评论

I'm using a tabs template for an Ionic project and have set the a background image. However, when the transition throw states occurs, the background is also affected by the animation. I want that the background always stay fixed on entire application ( on transition throw states and sub-states).

This project exemplifies the problem:

link:

I also tried to assign the background property to the body but it doesn't work.

So, does anybody know how to always keep the background image fixed and only animate the content ?

I'm using a tabs template for an Ionic project and have set the a background image. However, when the transition throw states occurs, the background is also affected by the animation. I want that the background always stay fixed on entire application ( on transition throw states and sub-states).

This project exemplifies the problem:

link: http://codepen.io/anon/pen/ogYymB

I also tried to assign the background property to the body but it doesn't work.

So, does anybody know how to always keep the background image fixed and only animate the content ?

Share Improve this question edited Jan 5, 2015 at 16:02 semirturgay 4,2013 gold badges31 silver badges50 bronze badges asked Jan 5, 2015 at 14:50 mmarquesmmarques 6553 gold badges9 silver badges29 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 1

So, there are some new plications because of some new features in beta 14, but you can still acplish what you want using only CSS.

See this pen:

http://codepen.io/andrewmcgivery/pen/azBjdB

Relevant CSS:

body {
    background: 
url(http://cdn.wonderfulengineering./wp-content/uploads/2014/07/background-wallpapers-32.jpg) ;
    background-attachment:fixed;
    background-position: center;
}

body .view-container.tab-content {
  background-color: transparent;
}

body .pane, .menu, .view, .list, .item       {
    background: transparent;
}

I think that you can't achieve what you are trying to do because it's a javascript framework implementation. When you change url (e.g. "/sign-in") the framework preoload the html of that page and then replace all the html document with the new one using a transition. In this html is included the background also. I think that for your purpose you should implement your own function that (for example) replaces only the div container html with a transition. In this way the background should remain fixed.

I had a similar problem and the only thing I did was change the scss style to include the following class:

.transparent      {
    background: transparent;
}

Which I added to the ion-view.

发布评论

评论列表(0)

  1. 暂无评论