Skip to main content
The Deno 2 Release Candidate is here
Learn more

import lib

import {
    f_add_css,
} from "./client.module.js"
// } from "https://deno.land/x/f_add_css@[version]/mod.js"

most basic example add css by a string

f_add_css('*{margin:0; padding:0; font-family:sans}')

more complex string using the power of js .map and .join

f_add_css(
  [
    `*{
      margin:0; 
      padding: 0;
      color: orange;
    }`,
    [
      `
        p{color:red}
      `, 
      `
        h2{color:blue}
      `, 
    ].map(s=>`.my_prefix_class ${s}`).join("\r\n")
  ].join('r\n')
)

add a css via url

f_add_css(
  'https://cdn.simplecss.org/simple.css'
)

add a css to a certain document

f_add_css(
  '*{color:red !important}',
  document.querySelector('iframe').contentWindow.document, 
)