2016-08-09 10 views
1

私はイオン性アプリを持っています。 クラスのスクロールが自動的にアクティブになっているときにdivを実装するときに問題があります。</イオン含有量>の下限div

enter image description here

私はこのstucture有する:

<ion-view> 
    <ion-nav-title>Ionic test</ion-nav-title> 
    <ion-content> 
     <div style="background-color: red; height: 200px;"></div> 
     <div class="bar bar-footer bar-balanced"> 
      <div class="title">Footer</div> 
     </div> 
    </ion-content> 
</ion-view> 

をI底と絶対位置しようとしたが、仕事をdin't。

しかし、divが下

おかげで決してありません!

答えて

0

1.オプション - 画面上に常にフッター。

<ion-content>class="has-footer"を追加し、代わりにこのような

<div class="bar bar-footer bar-balanced"> 
      <div class="title">Footer</div> 
     </div> 

使用

<ion-footer-bar align-title="center" class="bar-balanced"> 
    <h1 class="title">Footer</h1> 
</ion-footer-bar> 

の:

<ion-view> 
    <ion-nav-title>Ionic test</ion-nav-title> 
    <ion-content class="has-footer"> 
    <div style="background-color: red; height: 200px;"></div> 
</ion-content> 
<ion-footer-bar align-title="center" class="bar-balanced"> 
    <h1 class="title">Footer</h1> 
</ion-footer-bar> 
</ion-view> 

enter image description here


2.オプション - フッタは、スクロールがアクティブな場合にのみ表示されます(used codepen)。

angular.module('ionicApp', ['ionic']) 
 

 
.directive('stickyFooter', function($document) { 
 
    return { 
 
    restrict: 'A', 
 
    link: function($scope, $element, $attr) { 
 
     var footer = $document[0].querySelector('.stickyFooter'); 
 
     var content, height, reverse, x; 
 
     $element.bind('scroll', function(e) { 
 
     content = $document[0].querySelector('.scroll-content').offsetHeight; 
 
     height = $document[0].querySelector('.scroll').offsetHeight; 
 
     reverse = -footer.offsetHeight; 
 
     x = height + reverse - e.detail.scrollTop - content; 
 
     if (x>reverse && x<=0) { 
 
      footer.style[ionic.CSS.TRANSFORM] = 'translate3d(0,'+x+'px,0)'; 
 
     } else if (x<=reverse) { 
 
      footer.style[ionic.CSS.TRANSFORM] = 'translate3d(0,'+reverse+',0)'; 
 
     } else { 
 
      footer.style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)'; 
 
     } 
 
     // console.log(e.detail.scrollTop); 
 
     }); 
 
    } 
 
    } 
 
}) 
 

 
.controller('MyCtrl', function($scope, $document, $ionicPosition) { 
 
    
 
    $scope.items = [ 
 
    { id: 0 }, 
 
    { id: 1 }, 
 
    { id: 2 }, 
 
    { id: 3 }, 
 
    { id: 4 }, 
 
    { id: 5 }, 
 
    { id: 6 }, 
 
    { id: 7 }, 
 
    { id: 8 }, 
 
    { id: 9 }, 
 
    { id: 10 }, 
 
    { id: 11 }, 
 
    { id: 12 } 
 
    ]; 
 
    
 
});
p { 
 
    padding: 20px !important; } 
 
.stickyFooter { 
 
    padding: 20px; 
 
    width: 100%; 
 
    background: grey; 
 
    bottom: -60px; 
 
    position: absolute; 
 
    
 
    -webkit-animation: fadein 10s; /* Safari, Chrome and Opera > 12.1 */ 
 
     -moz-animation: fadein 10s; /* Firefox < 16 */ 
 
     -ms-animation: fadein 10s; /* Internet Explorer */ 
 
     -o-animation: fadein 10s; /* Opera < 12.1 */ 
 
      animation: fadein 10s; 
 

 
} 
 
ion-content[sticky-footer] .scroll { 
 
    padding-bottom: 60px; } 
 

 
/*FadeIN */ 
 

 
@keyframes fadein { 
 
    from { opacity: 0; } 
 
    to { opacity: 1; } 
 
} 
 

 
/* Firefox < 16 */ 
 
@-moz-keyframes fadein { 
 
    from { opacity: 0; } 
 
    to { opacity: 1; } 
 
} 
 

 
/* Safari, Chrome and Opera > 12.1 */ 
 
@-webkit-keyframes fadein { 
 
    from { opacity: 0; } 
 
    to { opacity: 1; } 
 
} 
 

 
/* Internet Explorer */ 
 
@-ms-keyframes fadein { 
 
    from { opacity: 0; } 
 
    to { opacity: 1; } 
 
} 
 

 
/* Opera < 12.1 */ 
 
@-o-keyframes fadein { 
 
    from { opacity: 0; } 
 
    to { opacity: 1; } 
 
}
<html ng-app="ionicApp"> 
 
    <head> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
 
    <title>Ionic List Directive</title> 
 
    
 
    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet"> 
 
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script> 
 
    </head> 
 

 
    <body ng-controller="MyCtrl"> 
 
    
 
    <ion-header-bar class="bar-positive"> 
 
     <div class="buttons"> 
 
     <h1 class="title">Ionic test</h1> 
 
     </div> 
 
    </ion-header-bar> 
 

 
    <ion-content sticky-footer scroll-event-interval="1"> 
 
     
 
     <p>This is some data.</p> 
 
     
 
     <ion-list> 
 

 
     <ion-item ng-repeat="item in items" item="item"> 
 
      Item {{ item.id }} 
 
     </ion-item> 
 

 
     </ion-list> 
 

 
    </ion-content> 
 
     
 
    <!-- Here's the stiky footer --> 
 
     
 
    <div class="stickyFooter">Footer.</div> 
 
     
 
    </body> 
 
</html>

+0

は、あなたの答えをありがとう、それだ しかし、私はフッターを望んでいたが。 divは20ピクセル下になり、スクロールが表示されたとき これは常に固定で表示されます。 – user2209728

+0

@ user2209728このようなものhttp://codepen.io/xAlien95/pen/PwbPdr? –

+0

それはそれです:)しかし、 4の項目でフッターに問題があります。 http://codepen.io/anon/pen/LkrWdv しかし、フェードインとフェードアウト。 可能ですか? – user2209728

関連する問題