twitter-bootstrap 我可以只使用 Twitter Bootstrap 的某些元素吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16098758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 16:56:41  来源:igfitidea点击:

Can I use only certain elements of Twitter Bootstrap?

htmltwitter-bootstrapcss

提问by doniyor

Can I use only some certain elements of bootstrap library? For example, if I import the whole library, my page breaks because of conflicts between my CSS and Bootstrap's CSS; they are overwriting each other's properties.

我可以只使用引导库的某些元素吗?例如,如果我导入整个库,由于我的 CSS 和 Bootstrap 的 CSS 之间的冲突,我的页面会中断;他们正在覆盖彼此的属性。

If possible, I want something like just the button and div styling properties of the Bootstrap library.

如果可能,我想要一些类似于 Bootstrap 库的按钮和 div 样式属性的东西。

回答by Pigueiras

You can download whatever you need in the customized download of Twitter Bootstrap page. Just select whatever you need and click on download.

您可以在Twitter Bootstrap 页面自定义下载中下载您需要的任何内容。只需选择您需要的任何内容,然后单击下载。

Also you can go to the project official repository, download all the less files, and compile only what is necessary for you, commenting the lines of the files that you don't need in the bootstrap.lessfile.

你也可以去项目官方仓库,下载所有less文件,只编译你需要的,在bootstrap.less文件中注释你不需要的文件行。

回答by NielsC

Well I suggest you take the specific CSS rules out of the bootstrap CSS file and place them in your own CSS file, because it's kind of useless if you include the whole bootstrap CSS file in your website and then just 1 or 2 CSS rules of it.

好吧,我建议您从 bootstrap CSS 文件中取出特定的 CSS 规则并将它们放在您自己的 CSS 文件中,因为如果您将整个 bootstrap CSS 文件包含在您的网站中,然后只包含其中的 1 或 2 个 CSS 规则,那将毫无用处.

You could also try to place the bootstrap CSS file first and then your CSS file after it in the HEAD section of your website. Usually your CSS file will be "more important" and then the specific styles which are applied by bootstrap will be overridden with your own rules.

您也可以尝试先将引导 CSS 文件放在您网站的 HEAD 部分,然后再将您的 CSS 文件放在它的后面。通常,您的 CSS 文件将“更重要”,然后引导程序应用的特定样式将被您自己的规则覆盖。

<link bootstrap css definition />
<link your css definition />