Returns padding top percentage value when passed an aspect ratio string seperated by a colon, eg 4:3 returns 75.

Parameters:
NameTypeDescription
ratiostring

The ratio in form w:h.

Since
  • 1.3.1
Returns:

Returns the percentage as number without any symbol.

Type: 
number
Example
import { aspectRatioToPadding } from "@gravityforms/utils";

function Example() {
  const div = document.createElement( 'div' );
  const ratio = '16:10';
  div.style.paddingTop = `${ aspectRatioToPadding( ratio ) }%`;
}