How do I deal with the custom part when I use Bootstrap?

Asked 2 years ago, Updated 2 years ago, 41 views

I want to develop a website using the Bootstrap design.

When I looked at the bootstrap site, the CDN link was introduced, so I used it. (I don't know if you usually use bootstrap as a CDN link. )

After that, I'd like to customize the color of a specific part, but is there any way?

I would like to ask you which method is the most efficient to use, such as the !import attribute. (This is the first time to develop a website, so you may be misdirected, so please give me the right direction advice.)

ps.

I applied the beginner template as above.

And change the color of the menu bar...

bootstrap css html5

2022-09-21 17:02

3 Answers

Typically, you override the CSS. I think we can change the loading order of CSS rather than using !important.

First, load the CSS of Bootstrap, then load the CSS of the changed theme.

If duplicate settings exist due to CSS characteristics, follow the last declared statement. However, for properties defined as !important, it can only be overridden by !important.

Here is an example. Example of overriding the class of CSS defined in bootstrap using tags after css loading. A simple example of changing the color when applying navbar-inverse to the navigation bar of the bootstrap.

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<style>
.navbar-inverse {
  background-color: #248
  border-color: #103070;
}
.navbar-inverse .navbar-brand {
    color: #eee;
}
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:hover, .navbar-inverse .navbar-nav>.active>a:focus {
    color: #fff;
    background-color: #103070;
}
</style>

I think it would be better if you design it by making changes overall like the above, or borrow the ones that have already been designed, such as https://wrapbootstrap.com/ and modify them.


2022-09-21 17:02

If you do simple customization, the method that Heo Dae-young told you is the simplest, and at first, you will use this method the most.

If you want to customize in detail, you can set it to your liking at http://getbootstrap.com/customize.

There is also a http://bootstrap-live-customizer.com site for easier viewing.

If you're more professional, you can customize a project like bootstrap/bootstrap-sass. If you get used to css a little, I recommend you to move on to a preprocessor like sass. There will be a lot of difference in productivity.

Reference

(Almost all cases) Avoid !important.

If you just understand the priority of css selector and use it, it will be much easier to maintain the code.

http://bitsofco.de/on-not-and-specificity/


2022-09-21 17:02

I recommend this place. You can test real-time by changing colors and fonts in real-time, so it's good to use without having to peel the core ends. Note that only version 3.3.6 is supported. http://bootstrap-live-customizer.com/


2022-09-21 17:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.