简体   繁体   中英

How to set height and width of :before by using JavaScript

I got a CSS3 tag called body:before , and I want to use JavaScript to set the height and width of body:before .

How can I do that?

You can't. One possiblity is to use a class or ID:

.someClass:before {
    /*Styles here*/
}

You can then apply the someClass class to the elements in question by setting the className property:

yourElement.className = "someClass";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM