Returns padding top percentage value when passed an aspect ratio string seperated by a colon, eg 4:3 returns 75.
Parameters:
Name | Type | Description |
---|---|---|
ratio | string | The ratio in form |
- 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 ) }%`;
}