For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Sunday, March 10, 2024

Apply CSS via JavaScript

 

Here is the example where apply css via JavaScript

<script>

const mstyle = document.head.appendChild(document.createElement(‘style’));
style.textContent = /*this is the css*/`

.myclass {
aspect-ratio: 16 / 9; background-color: #000;
position: relative; display: block; contain: content;
background-position: center center;
background-size: cover;

}

#mydivid {
color:green; opacity: 0;
}
`;

</script>

Share:

0 comments:

Post a Comment

Add Dependent Scripts

   here is the code that allow to add dependent script :         <script>         const addDependentScripts = async function( scriptsT...

Ads Inside Post

Powered by Blogger.

Arsip