Get started with lit-grid-layout CDN
MIT licensed
Lightweight CSS grid library: Lit-Grid-Layout builds responsive JS layouts.
Tags:- typescript
- javascript
- grid
- layout
- lit-element
Stable version
Copied!
How to start using lit-grid-layout CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with lit-grid-layout CDN - cdnhub.io</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lit-html.min.js"></script>
<script src="https://cdn.cdnhub.io/lit-grid-layout/1.1.15/lit-grid-layout.js"></script>
<style>
:host {
display: contents;
}
</style>
</head>
<body>
<div id="grid">
<template id="item-template">
<div class="item">
<slot></slot>
</div>
</template>
<lit-grid-layout id="grid-layout" rows="auto" columns="auto" gap="10px">
<template is="repeat" items="[[items]]">
<lit-grid-item id="item-[[index]]" xs="12" sm="6" md="4">
<template is="dom-repeat" items="[[item.content]]" as="content">
<div slot="content">{{ content }}</div>
</template>
</lit-grid-item>
</template>
</lit-grid-layout>
</div>
</body>
<script>
const items = [
{ content: 'Item 1' },
{ content: 'Item 2' },
{ content: 'Item 3' },
{ content: 'Item 4' },
{ content: 'Item 5' },
];
customElements.define('my-grid', class extends HTMLElement {
static get template() { return document.getElementById('item-template').content; }
static get properties() { return { items: { type: Array } }; }
constructor() {
super();
this.attachShadow({ mode: 'open' }).appendChild(this.template.cloneNode(true));
this.items = items;
this.shadowRoot.querySelector('#grid-layout').items = this.items;
}
});
document.addEventListener('DOMContentLoaded', () => {
customElements.get('my-grid').render();
});
</script>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!