Why HTML5 Canvas with a larger size stretch a drawn line?

I am using a HTML5 <canvas> to draw lines on.

When I change the dimensions from the default of 300x150 to match the dimensions of another <div> my lines appear stretched and are thicker than before. Why is this happening?

I want to draw the lines on the canvas to match the position of elements on the <div> that is in front of it (with a higher z-index) in the same position on the page. How can I stop this stretching from happening?

<strong>EDIT:</strong> This appears only to be in Firefox.


You can't change canvas size with CSS. If you do it will behave like an image and it will stretch You have to do it in javascript with canvas properties canvas.width, canvas.height


  • Generating QR codes in google-spreadsheet
  • Increase size of Dots in Progress bar windows phone 8
  • Play button centred with different image/video sizes
  • Jfree chart change Y axis data
  • Can't get the function to work with checkbuttons using tkinter
  • Why box-sizing is not working with width/height attribute on canvas element?
  • Android 4.2 9-patch background drawn differently than older OS versions
  • cocos2dx+box2d:Object stops abruptly, tied two ropes
  • Check a point location in a particular area on html canvas
  • WP7 - issues with Horizontal scrolling Listbox
  • as3 addChild into a generated triangle
  • How to make image control button for each image inside the div using css and js?
  • resize image using tkinter
  • Why does this use of getImageData leak memory
  • Differences between drawing an Ellipse in Android and Java
  • Remove previous Directions Route Google Maps
  • write text on image and show it to a imageview
  • How to draw a line dynamically in android [duplicate]
  • Get specific string
  • How does document.ready work with angular element directives?
  • Chart.js Multiple dataset
  • GridView breaks while scrolling
  • Blackberry - Custom EditField Cursor
  • preg_replace Double Spaces to tab (\\t) at the beginning of a line
  • How to use remove-erase idiom for removing empty vectors in a vector?
  • Extracting HTML between tags
  • FileReader+canvas image loading problem
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Body moving without any force applied? (Box2d)
  • Insert into database using onclick function
  • Deselecting radio buttons while keeping the View Model in synch
  • Controls, properties, events and timers running in design time
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Modifying destination and filename of gulp-svg-sprite
  • When should I choose bucket sort over other sorting algorithms?
  • GridView Sorting works once only
  • How do I rollback to a specific git commit
  • Unanticipated behavior
  • Android Google Maps API OnLocationChanged only called once
  • Android Heatmap on canvas or ImageView