aspect-ratio-element
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Aspect Ratio Element

Installation

Install via NPM.

npm install aspect-ratio-element

Information

This library registers <aspect-ratio> using the Custom Elements API.

<!-- Upright A4 Paper -->
<aspect-ratio style="--aspect-ratio: calc(1/1.4142)">
	<div class="paper"></div>
</aspect-ratio>

Why not just use CSS?

CSS has a new property called aspect-ratio, but:

  • The element is not constrained on both axes.
  • The element's intrinsic size takes priority.
  • Safari (incorrectly) requires the element's width or height to be set, preventing its use in layouts that don't use explicit width or height.

License

MIT License

All files can be used for commercial or non-commercial purposes. Do not resell. Attribution is appreciated but not due.

/aspect-ratio-element/

    Package Sidebar

    Install

    npm i aspect-ratio-element

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    4.71 kB

    Total Files

    5

    Last publish

    Collaborators

    • cymaera