简体   繁体   中英

Applying font styles to elements inside CSS

Is there a way to apply a font style or any other style to an element inside CSS?

For instance

You defined a certain font style

.impact {       
    font-family: "Impact"; 
    letter-spacing: 16px;  
    line-height: 72%;
}

Now apply this style to an element inside css:

#certainElement {
     font-family: Impact (the one we defined)
     width: 400px;
}

Unfortunately, CSS does not support this kind of composition. However, you can use SASS or LESS to get similar behavior.

Is there any reason that defining a class on your element with id certainElement isn't desirable?

<div id="certainElement" class="impact"></div>

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