2013-08-02 58 views
0

如果我調整瀏覽器的屏幕大小,由html5 canvas創建的動畫會移動到瀏覽器中的不同位置,例如,原始位置在右上角,將瀏覽器屏幕拖動到小尺寸後,位置爲在右下角,我該如何修復瀏覽器中html5 canvas元素的位置?如何在瀏覽器屏幕中修復html5 canvas元素的位置?

+0

請包括產生此問題的代碼。 – K3N

回答

0

類似:

//Get the canvas & 
var c = $('#canv'),  
    container = $(c).parent(); 

//Run function when browser resizes 
$(window).resize(canvasRemake); 

function canvasRemake(){ 
    c.attr('width', $(container).width()); 
    c.attr('height', $(container).height()); 

    //Call a function to redraw other content (texts, images etc) 
} 

注:會殺了你的動畫,那麼,關於與頁面勒金,因此,如果瀏覽器中得到小,用戶將不得不滾動看到動畫...

just a tho *

相關問題