let heightStr = '56.54px'; let number = parseFloat(heightStr.replace('px', '')); console.log(number) // or on a DOM Element const message = document.querySelector('.message-container'); console.log(getComputedStyle(message).height); message.style.height = Number.parseFloat(getComputedStyle(message).height, 10) + 22.5 + 'px';
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter