How to break CSS inheritance?

前端 未结 5 1630
再見小時候
再見小時候 2020-12-11 17:20

I have created a web widget. That my client put in their websites. Basically on load it calls webservice and loads data specific to client.

As a result it looks like

5条回答
  •  借酒劲吻你
    2020-12-11 17:38

    Use of the !important css attribute is considered a bad practice. Because it introduces the potential for precedence conflicts, and makes it extremely difficult to troubleshoot css in the long run.

    A less intrusive approach to this problem is to delimit your widget with an id, and in your stylesheet, to reset some of the most important style declarations using the "universal" selector, such as:

    #myWidget *{
      margin: 0;
      padding: 0;
      background: none;
      border: none;
    }
    

    For example. Then, define your overrides specifically.

提交回复
热议问题