Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

class - Mysterious SCSS Overriding my custom.scss

So I have a custom.scss file to override some bootstrap defaults. But these aren't being applied instead another color is being applied but it looks like it's from the same line of code from the same file?! That's impossible, right?

Any suggestions on where can I find this purple code to delete it? I searched the color #00242f in custom.scss but no search results. I searched in the directory to make sure there wasn't 2 X custom.scss files and it appears there is just the one. I'm pretty sure it doesn't live in custom.scss, so where does it live? Where is this coming from? enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here are the few points which can used to override the css from bootstrap

  • Please stop making use of !important for every class this will not only make your application more complex but it will be difficult to manage and scale up your application in future.
  • If you want to override the class, please create a parent class the follow the hierarchy and the override it without making use of !important Override class without using !important
  • Also request you to please go through Specificity in CSS. This will be helpful in understanding which element need to placed where and get rid of !important
  • As per your screenshot I can see you are using plane css in scss file though there is no harm into it, however, you are not utilising the power/features of scss. Such as @extent, @include, variables, mixing, functions, etc. Please check this SCSS Features
  • Due to which your file size is becoming huge its already more than 6100 lines of code into. If we keep on overriding all the classes like this. Then it would be difficult to find and keep the correct code.
  • Please break your code into small pieces in term of reusable code. Such as button.scss, background-color.scss, variables.scss and import them at the top of custom.scss file. This will make your code cleaner smaller and more dynamic
  • If you are using Bootstrap 4 then please check BEM Methodology BEM for writing css classes.
  • Since Bootstrap 4 is already using BEM standards for writing their default classes.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...