UNPKG

@diddledan/proportional-height-box

Version:

Web component to resize child element to proportional height based on the width similar to fitvids

54 lines (45 loc) 1.95 kB
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> <title>proportional-height-box demo</title> <script type="text/javascript" src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> <script type="module"> import '@polymer/iron-demo-helpers/demo-snippet.js'; import '@polymer/paper-checkbox/paper-checkbox.js'; import '../proportional-height-box.js'; </script> <!-- FIXME(polymer-modulizer): These imperative modules that innerHTML your HTML are a hacky way to be sure that any mixins in included style modules are ready before any elements that reference them are instantiated, otherwise the CSS @apply mixin polyfill won't be able to expand the underlying CSS custom properties. See: https://github.com/Polymer/polymer-modulizer/issues/154 --> <script type="module"> const $_documentContainer = document.createElement('template'); $_documentContainer.innerHTML = `<style is="custom-style" include="demo-pages-shared-styles"> </style>`; document.head.appendChild($_documentContainer.content); </script> </head> <body> <script type="module"> const $_documentContainer = document.createElement('template'); $_documentContainer.innerHTML = `<div class="vertical-section-container centered"> <h3>Basic proportional-height-box demo</h3> <p>Try resizing your browser</p> <demo-snippet> <template> <proportional-height-box width="300" height="200"> <img src="http://lorempixel.com/g/300/200/cats/"> </proportional-height-box> </template> </demo-snippet> </div>`; document.body.appendChild($_documentContainer.content); </script> </body> </html>