是否可以排除一个特定div容器的所有css样式? [英] Is it possible to exclude all css styling for one specific div container?

查看:482
本文介绍了是否可以排除一个特定div容器的所有css样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用 font-face 时遇到问题。我可以得到它的工作,当测试它在一个html文件与自己的样式,但不是如果我包括其他样式表。

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.

我试过覆盖stles,

I've tried overriding stles, placing style sheets in different order and so on, but nothing works.

所以我想知道,是否可以排除所有的CSS,只使用css从一个css文件为一个具体的div容器?

So I'm wondering, is it possible to exclude all CSS and only use css from one css file for a specific div container?

(不使用 iframe

推荐答案

不幸的是,不可能只是清除或重置特定容器的样式从它继承的CSS。你必须手动覆盖每个样式。

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;
}

您当然可以将!important 您需要并向列表中添加更多元素。如果您不能信任或不知道将要加载并应用于您的网页的其他样式,我认为最好是从一个空白的开始。

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.

这篇关于是否可以排除一个特定div容器的所有css样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆