question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overriding bootstrap styles

See original GitHub issue

Hi guys,

This is probably a very stupid question, but …

I’ve imported bootstrap into my create-react-app project as per the documentation (very nice).

However when I look at the generated markup, all the <style> tags for my components e.g. Header.css come before the bootstrap css, which means I can’t (easily) override bootstraps default styling.

Is there a way to ensure bootstrap gets put before other css files?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
viankakrisnacommented, Feb 22, 2017

try to move the css imports above import Routes from './routes'; I think that’s because style-loader reads the css imported from components in Routes first rather than bootstrap. like this

import React from 'react';
import ReactDOM from 'react-dom';
import { browserHistory } from 'react-router';

import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';

import './index.css';

import Routes from './routes';

ReactDOM.render(
  <Routes history={browserHistory} />,
  document.getElementById('root')
);

And see if it works

0reactions
jaredgalaniscommented, Sep 10, 2017

For some reason this is not working for me. The index.js file does look different at this point. There’s no import of Routes.

import 'bootstrap/dist/css/bootstrap.css';

import './index.css';
import './SelectOption.css';

import React from 'react';
import ReactDOM from 'react-dom';

import PlayerContainer from './PlayerContainer';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<PlayerContainer />, document.getElementById('root'));
registerServiceWorker();
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Edit, Customize, and Override Bootstrap CSS to Suit ...
You can override the default styles of Bootstrap elements using two possible methods. The first way — using CSS overrides— applies to sites ......
Read more >
How can I override Bootstrap CSS styles? - Stack Overflow
Yes, overrides should be put in a separate styles.css (or custom.css ) file so that the bootstrap.css remains unmodified. This makes it easier ......
Read more >
How to override Bootstrap CSS? - Themesberg
The most straightforward way of overriding Bootstrap styles is using plain old CSS. In this case, you will need to include your own...
Read more >
How To Override Default Bootstrap CSS Styles - BootstrapDash
Import the bootstrap variables and functions into the custom.scss file. Now, add the code to change bootstrap default theme-colors and then add the...
Read more >
Bootstrap custom CSS overrides - YouTube
We continue building our website implementing custom CSS and learning how to override the Bootstrap CSS.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found