operate-css
Insert CSS into head, or insert CSS attributes into any element. npm -> operate-css。
usage
install
yarn add dom
npm install dom
import dom from 'dom'
css({ el, styles }: { el: { style: { [x: string]: any } }; styles: { [x: string]: any } })
const el = document.getElementById('#dom')
const styles = {
color: 'red',
backgroundColor: 'lightblue'
}
dom.css(el, styles)
getStyleValue({ el, attr }: { el: HTMLElement; attr: string; })
const el = document.getElementById('#dom')
dom.getStyleValue(el, 'backgroundColor')
insertCSS(css: string, options: { target?: any; prepend?: boolean })
const css = 'body { background:blue; }'
const options = {
target: 'head',
prepend: true
}
dom.insertCSS(css, options)