1

When I import Bootstrap CSS it adds extra CSS to the navbar. As it is shown in the image below. I am using bootstrap cards in this code but not for Navbar. When I remove the Bootstrap CSS It works fine.

enter image description here

You can check the code here

Please help me resolve this.

4
  • It adds extra css because bootstrap has their own css for the class name that you are using. So you could use different class names. Commented Jul 26, 2021 at 11:56
  • I add different class names in Navbar but it doesn't work. Commented Jul 26, 2021 at 11:58
  • what is the problem you are facing by adding Bootstrap CSS? Commented Jul 26, 2021 at 12:16
  • You can check the image. When I import bootstrap it puts underlines in the navigation item and even change font size and style. Commented Jul 26, 2021 at 12:27

2 Answers 2

2

if your problem is the under line you can omit that using

style={{ textDecoration: 'none' }}

here is your modified navbar.jsx file

// eslint-disable-next-line
import React from 'react';
import { NavLink } from 'react-router-dom';

function Navbar(){
    return(
        <>
            <header className="l-header"> 
                <div className="navi bd-grid">
                    <div>
                        <NavLink to="#" className="navi__logo">Portfolio</NavLink>
                    </div>

                    <div className="navi__menu" id="navi-menu">
                        <ul className="navi__list">
                            <li className="navi__item">
                                <NavLink to="#home" className="navi__link menu" style={{ textDecoration: 'none' }}>Home</NavLink>
                            </li>
                            <li className="navi__item">
                                <NavLink to="#about" className="navi__link" style={{ textDecoration: 'none' }}>About</NavLink>
                            </li>
                            <li className="navi__item">
                                <NavLink to="#skills" className="navi__link" style={{ textDecoration: 'none' }}>Skills</NavLink>
                            </li>
                            <li className="navi__item">
                                <NavLink to="#work" className="navi__link" style={{ textDecoration: 'none' }}>Work</NavLink>
                            </li>
                            <li className="navi__item">
                                <NavLink to="#contact" className="navi__link" style={{ textDecoration: 'none' }}>Contact</NavLink>
                            </li>
                        </ul>
                    </div>

                    <div className="navi__toggle" id="navi-toggle">
                        <i className='bx bx-menu'></i>
                    </div>
                </div>
            </header>
        </>
    );
};

export default Navbar;

output will be something like this enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Yes It removes the underline but navigation stops working.
0

Try to import the bootstrap on your index.js file and it should solve the problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.