将外部CSS应用于特定区域 [英] apply external CSS to specific area

查看:95
本文介绍了将外部CSS应用于特定区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将外部CSS(例如 Bootstrap )汇入我的网站,问题是我' d仅将引导样式应用于页面的特定区域。当我包含Bootstrap时,它将其样式应用到整个页面,重新整理所有表,div等。

I'd like to import an external CSS (eg. Bootstrap) into my site-- the problem is I'd like to apply the Bootstrap styles only to a specific region of the page. When I include Bootstrap, it applies its styles to the entire page, restyling all tables, divs, etc.

是否可以只将引导应用到一个区域父div或某事?)

Is it possible to only apply Bootstrap to a region (say a parent div or something?)

感谢

推荐答案

要做到这一点是有一个单独的iframe的内容,你想用Bootstrap风格(除非你想编辑Bootstrap CSS,并添加你的外部div的选择器到EVERY规则的开头)。

The only way to do this is to have a separate iframe for the content you want to style with Bootstrap (unless you want to edit the Bootstrap CSS, and add your outer div's selector to the beginning of EVERY rule).

HTML5引入了新的作用域属性,具体做了

HTML5 introduced the new scoped attribute, which is made specifically for your use case, but has not yet been implemented by any one of the major browsers.

如果你使用jQuery(你可能是,因为所有的Bootstrap的Javascript功能取决于jQuery),您可以尝试 Simon Madine的jQuery Scoped CSS插件

If you are using jQuery (which you probably are, since all of Bootstrap's Javascript functionality is dependent upon jQuery), you might wanna try Simon Madine's jQuery Scoped CSS plugin.

这篇关于将外部CSS应用于特定区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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