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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip