2016-08-04 33 views
0

我有一個頁腳圖像,點擊返回到主頁。 但是,圖像應始終可見。所以當移動鍵盤出現時,圖像應該跳到鍵盤上方。如何使頁腳圖像跳轉到移動鍵盤上

任何想法如何做到這一點?

enter image description here

編輯:

這裏是我的指令累,但手機鍵盤時會出現圖像不向上移動。鍵盤隱藏圖像:

(function() { 

'use strict'; 

angular 
    .module('TestApp') 
    .directive('stickyText', ['$mdSticky', stickyText]); 

function stickyText($mdSticky) { 
    return { 
     restrict: 'E', 
     template: '<span style="position: absolute; right: 0; bottom: 0;"> <img src="assets/img/icons/home.png" style="width:40px;height:40px;"> </span>', 
     link: function (scope, element) { 
      $mdSticky(scope, element); 
     } 
    } 
} 

})(); 

HTML代碼:

<sticky-text ui-sref="home"> </sticky-text> 
+0

你能分享css代碼嗎? –

+0

我同意@Rocky,我們需要看看你現在有什麼CSS。 – George

+0

你好,我添加了我爲粘性圖像寫的指令。 CSS只包含「position:absolute; right:0; bottom:0;」將圖像定位在右下角 – Veela

回答

0

我設法用下面的jQuery移動鍵盤上方的頁腳:

$('form').on('focus', 'input, textarea', function() { 
     $("footer").addClass('aboveKeyboard'); 
    }); 

    $('form').on('blur', 'input, textarea', function() { 
     $("footer").removeClass('aboveKeyboard'); 
    }); 

CSS:

.aboveKeyboard img{ 
top :30%; 
} 

HTML:

<footer ui-sref="homepg"> 
    <img src="thumb_home.png" style="position: absolute; right: 0;bottom: 0;"> 
</footer> 
相關問題