Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check string length pixel "react"

function getTextWidth(text, font) {
  const canvas = document.createElement('canvas');
  const context = canvas.getContext('2d');

  context.font = font || getComputedStyle(document.body).font;

  return context.measureText(text).width;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #string #length #pixel
ADD COMMENT
Topic
Name
5+3 =