grid 布局
This commit is contained in:
parent
5cbc817840
commit
8b12e63fbb
12
main.js
12
main.js
@ -20,6 +20,9 @@ export function createElement({ innerText, innerHTML, textContent, readOnly, chi
|
|||||||
element.childs = (childs) => { childs.forEach(child => element.appendChild(child)); return element }
|
element.childs = (childs) => { childs.forEach(child => element.appendChild(child)); return element }
|
||||||
element.bg = (color) => { element.style.backgroundColor = color; return element }
|
element.bg = (color) => { element.style.backgroundColor = color; return element }
|
||||||
element.p = (padding) => { element.style.padding = padding; 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
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +52,15 @@ export class BaseElement {
|
|||||||
static p(padding) {
|
static p(padding) {
|
||||||
return createElement({ style: { padding } }, this.name)
|
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 {
|
export class div extends BaseElement {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@laniakeasupercluster/widgets",
|
"name": "@laniakeasupercluster/widgets",
|
||||||
"description": "A simple widgets tracker",
|
"description": "A simple widgets tracker",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"author": "Laniakea Supercluster <huan0016@gmail.com>",
|
"author": "Laniakea Supercluster <huan0016@gmail.com>",
|
||||||
|
Loading…
Reference in New Issue
Block a user