简体   繁体   English

覆盖Bootstrap CSS的最有效方法是什么?

[英]What is the most efficient way to override Bootstrap css?

I'm using Opencart for a E-Commerce site for my company. 我使用Opencart的一个电子商务网站为我的公司。 The Opencart developer is working on V2.0 which will incorporate Bootstrap as the default styling. Opencart开发人员正在开发V2.0,它将把Bootstrap作为默认样式。

My plan was to put a link in my header file on the next line BELOW the link to bootstrap stylesheet example: 我的计划是在链接到引导程序样式表示例的下一行的下一行中的头文件中放置一个链接:

<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/override.css" />

I was planning on using LESS to compile into override.css and only change small parts of the Bootstrap less to meet my needs. 我打算用LESS编译成override.css,只改变引导少的一小部分,以满足我的需求。 For example, I was planning on only including the variables.less from bootstrap along with buttons.less and layout.less. 例如,我打算只包括bootstrap中的variables.less以及button.less和layout.less。 I'd then compile those modified files into override.css to get my personalized styles. 然后我编译那些修改过的文件到override.css让我的个性化风格。 However, the more I think about it, I realize I'd need to include all the LESS from Bootstrap. 但是,我考虑得越多,我意识到我需要包括Bootstrap中的所有LESS。 This would make my override.css essentially the same as bootstrap.css (with the exception of the changes I make for my styling). 这将使我override.css基本相同,bootstrap.css(有变化我为我的造型除外)。

This essentially defeats the purpose of having an override. 这实际上违反了建立覆盖的目的。 Is there a way to not need to include ALL the bootstrap less, just the parts that I want in the override? 有没有一种方法不需要只包括所有我需要的引导程序,而不必覆盖我想要的部分?

People may be wondering why I don't just modify the bootstrap.css file. 人们也许会奇怪,为什么我不只是修改bootstrap.css文件。 My thought is that if I do modify the bootstrap.css file all my changes will be overwritten if I go to upgrade (or if the Opencart developer upgrades) bootstrap in the future. 我的想法是,如果我修改bootstrap.css文件,如果我将来升级(或者如果Opencart开发人员升级)bootstrap,我的所有更改都将被覆盖。

Any advise is much appreciated! 任何建议深表感谢!

Thanks! 谢谢!

DS-MATT DS-MATT

Why don't you keep an overwrite.css to yourself, while presenting compiled bootstrap.css + override.css to the end user? 为什么在向最终用户展示已编译的bootstrap.css + override.css ,不保留自己的overwrite.css That way you can easily update your bootstrap.css in the future and easily maintain the overrides themselves. 这样,您将来就可以轻松更新bootstrap.css并轻松维护覆盖本身。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 增加 CSS 特异性的最有效字符方法是什么? - What is the most character-efficient way to increase CSS specificity? 在 JavaScript 中解析 CSS 颜色的最有效方法是什么? - What is the most efficient way to parse a CSS color in JavaScript? 在Wordpress的CSS中更改所选页面的最有效方法是什么? - What is the most efficient way to make changes to a selection of pages in CSS for wordpress? 创建此javascript和CSS重项目的最有效方法是什么? - What would be the most efficient way to create this javascript and css heavy project? 用CSS在HTML中创建网格的最有效方法? - Most efficient way of creating a grid in HTML with CSS? 使用 JSX 或 Bootstrap 定位位于列表项上的锚元素的最有效方法是什么? - What is the most efficient way to position a anchor element that is located on a list item using JSX or Bootstrap JavaScript动态设置多种CSS样式以便将其应用于节点的最有效方法是什么? - What is the most efficient way in JavaScript to dynamically set multiple CSS styles so it applies to a node? 在编译的SASS css文件上处理合并冲突的最有效方法是什么? - What is the most efficient way to handle merge conflicts on your compiled SASS css file? 将CSS应用于列表而不更改页面上的每个列表的最有效方法是什么? - What is the most efficient way to apply CSS to a list without changing every single list on the page? 在已经包含其他页面的页面中包含.js和.css的最有效方法是什么? - What's the most efficient way to include .js and .css within pages already including other pages?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM