Is it possible to exclude all css styling for one specific div container?

后端 未结 2 1291
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 00:59

I\'m having problems using font-face on my website. I can get it working when testing it on a html file with it\'s own styling, but not if I include other style

相关标签:
2条回答
  • 2021-01-14 01:36

    Unfortunately no, it's not possible to just clear or reset the styles for a specific container from the css it's inherited. You have to override each style that you want manually.

    What you can do is you could namespace your classes and all you'd have to worry about would be element styles that you could define with defaults at the beginning of your style sheet. For example, something like:

    div,table,span,img,p{
        margin: 0;
        padding: 0;
        border: 0;
        font-weight: normal;
        font-style: normal;
        font-size: 100%;
        line-height: 1;
        font-family: inherit;
        text-align: left;
    }
    

    You can of course add !important to ones that you need and add more elements to the list. If you can't trust or don't know the other styles that are going to be loaded and applied to your page, I find it's best to just start with an empty slate.

    0 讨论(0)
  • 2021-01-14 01:45

    No, you cannot. There is no such exclusion mechanism in CSS or in HTML.

    You real problem is probably solvable, though, but you did not describe it. You should describe, in a new question, what you want, what you have tried, and how it fails. With real code and/or URL.

    0 讨论(0)
提交回复
热议问题