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 sheets.
我在我的网站上使用字体有问题。我可以在html文件中使用它自己的样式对它进行测试,但是如果我包含其他样式表,就不能这样做。
I've tried overriding stles, placing style sheets in different order and so on, but nothing works.
我试过压倒一切的东西,用不同的顺序摆放样式表等等,但是什么都没有。
So I'm wondering, is it possible to exclude all CSS and only use css from one css file for a specific div container?
所以我想知道,是否可以排除所有的CSS并且只在一个CSS文件中使用CSS作为一个特定的div容器?
(Without using iframe
)
(没有使用iframe)
2 个解决方案
#1
4
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.
不幸的是,不可能仅仅从继承的css中清除或重置特定容器的样式。您必须手动覆盖您想要的每个样式。
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.
您当然可以添加!对于您需要的元素来说很重要,并向列表中添加更多元素。如果你不相信或者不知道其他的样式会被加载并应用到你的页面上,我发现最好还是从一个空板开始。
#2
0
No, you cannot. There is no such exclusion mechanism in CSS or in HTML.
不,你不能。在CSS或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.
你真正的问题可能是可以解决的,但是你没有描述它。你应该在一个新的问题中描述你想要什么,你尝试过什么,以及它是如何失败的。使用真正的代码和/或URL。
#1
4
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.
不幸的是,不可能仅仅从继承的css中清除或重置特定容器的样式。您必须手动覆盖您想要的每个样式。
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.
您当然可以添加!对于您需要的元素来说很重要,并向列表中添加更多元素。如果你不相信或者不知道其他的样式会被加载并应用到你的页面上,我发现最好还是从一个空板开始。
#2
0
No, you cannot. There is no such exclusion mechanism in CSS or in HTML.
不,你不能。在CSS或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.
你真正的问题可能是可以解决的,但是你没有描述它。你应该在一个新的问题中描述你想要什么,你尝试过什么,以及它是如何失败的。使用真正的代码和/或URL。