grid 布局

This commit is contained in:
2024-05-16 05:24:43 +08:00
parent 5cbc817840
commit 8b12e63fbb
2 changed files with 13 additions and 1 deletions

12
main.js
View File

@ -20,6 +20,9 @@ export function createElement({ innerText, innerHTML, textContent, readOnly, chi
element.childs = (childs) => { childs.forEach(child => element.appendChild(child)); return element }
element.bg = (color) => { element.style.backgroundColor = color; return element }
element.p = (padding) => { element.style.padding = padding; return element }
element.m = (margin) => { element.style.margin = margin; return element }
element.grid = (options) => { element.style.display = 'grid'; Object.assign(element.style, options); return element }
element.flex = (options) => { element.style.display = 'flex'; Object.assign(element.style, options); return element }
return element
}
@ -49,6 +52,15 @@ export class BaseElement {
static p(padding) {
return createElement({ style: { padding } }, this.name)
}
static m(margin) {
return createElement({ style: { margin } }, this.name)
}
static grid(options) {
return createElement({ style: { display: 'grid', ...options } }, this.name)
}
static flex(options) {
return createElement({ style: { display: 'flex', ...options } }, this.name)
}
}
export class div extends BaseElement {

View File

@ -1,7 +1,7 @@
{
"name": "@laniakeasupercluster/widgets",
"description": "A simple widgets tracker",
"version": "1.1.1",
"version": "1.1.2",
"type": "module",
"main": "main.js",
"author": "Laniakea Supercluster <huan0016@gmail.com>",