javascript - Maximum width/height canvas scrollbar interference? -
I'm trying to get 100% width, height canvas element to attract, but because I grab 22 Chrome and Firefox both make scrollbar. The scrollbar appears here because the other related scrollbar makes the content longer / longer. That is, the vertical scrollbar is there because the bottom of the canvas is covered by the horizontal scrollbar and the horizontal scrollbar is there because the canvas right is covered by the vertical scrollbar. Any help is appreciated.
& lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 Strongly //n" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" lang = "en" xml: lang = "en" & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" src = "js / jquery.js" & gt; & Lt; / Script & gt; & Lt; Style & gt; * {Margin: 0; Padding: 0; } & Lt; / Style & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {var canvas = $ ("canvas"). Get (0); canvas.width = $ (document) .width (); canvas.height = $ (document). ); Var c = canvas.getContext ("2d"); c.fillStyle = "rgb (200,0,0)"; c.fillRect (0,0,5000,50); c.fillStyle = "rgba (0 , 0,200,0.5) "; c.fillRect (0,0,50,5000);}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Canvas & gt; & Lt; / Canvas & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Did you & lt; Body & gt;
? By default, it comes with some padding and margins, so if you have content that is "completely" fit, scrollbars will be because the padding and margin push the size.
Comments
Post a Comment