0

如果我调整浏览器的屏幕大小,html5画布创建的动画会移动到浏览器的不同位置,例如,原来的位置在右上角,将浏览器屏幕拖到小尺寸后,位置在右边下角,如何修复浏览器中 html5 画布元素的位置?

4

1 回答 1

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)
}

注意:这会杀死你的动画,那么页面的运气怎么样,所以如果浏览器变小,用户将不得不滚动才能看到动画......

只是一个*

于 2013-08-02T04:07:53.500 回答