Skip to content
Carlos Alba edited this page Nov 21, 2020 · 1 revision

ptpx

This is a utility that helps you pull percentages of pixels for example 0.1% or 100px is 10px this function basically just returns the percentage of pixels. This was created to use with iframes since the iframe API does not support percentage based heights and widths.

NOTE!: THIS WAS USED AS A HACKY but RELIABLE WORKAROUND for setting responsive (percentage based) heights for iframes and should not be used in any context where you could merely use percentages or responsive units for the same job.

EXAMPLE:

   <iframe height={`${ptpx(currentHeight, 0.95)}`} width={`${ptpx(currentWidth, 0.9)}`} ..... />
Clone this wiki locally