How can I disable inherited css styles?

前端 未结 7 1492
借酒劲吻你
借酒劲吻你 2021-02-02 08:27

So I am creating a container with rounded corners using the following method:

div.rounded {
    background: #CFFEB6 url(\'tr.gif\') no-repeat top right;
}
div.ro         


        
7条回答
  •  星月不相逢
    2021-02-02 09:02

    Cascading Style Sheet are designed for inheritance. Inheritance is intrinsic to their existence. If it wasn't built to be cascading, they would only be called "Style Sheets".

    That said, if an inherited style doesn't fit your needs, you'll have to override it with another style closer to the object. Forget about the notion of "blocking inheritance".

    You can also choose the more granular solution by giving styles to every individual objects, and not giving styles to the general tags like div, p, pre, etc.

    For example, you can use styles that start with # for objects with a specific ID:

    
    
    Hello world

    You can define classes for objects:

    
    
    Hello world

    Hope it helps.

提交回复
热议问题