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
267 views
in Technique[技术] by (71.8m points)

reactjs - Display ReactBootstrap Navbar inline

I am building a Website with react and I applied Reactbootstrap for Navbar and Carousel. For Footer MdBootstrap.

I get the Problem that my Navbar is not displayed inline and there is a padding right and left on navbar and Carousel.

Could someone please help me to fix that?

Here my CustomNavbar.jsx and CustomNavbar.css:

import React, { Component } from 'react'
import { Navbar, Nav, NavItem } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import './CustomNavbar.css'

export default class CustomNavbar extends Component {
  render() {
    return (
      <Navbar default collapseOnSelect fluid={true}>
        <Navbar.Header>
          <Navbar.Brand>
            <Link to="/">CodeLife</Link>
          </Navbar.Brand>
          <Navbar.Toggle/>
        </Navbar.Header>
        <Navbar.Collapse>

          <Nav>

            <NavItem eventKey={1} componentClass={Link} href="/" to="/">
              Home
            </NavItem>
  

            <NavItem eventKey={2} componentClass={Link} href="/about" to="/about">
              About
            </NavItem>
  
 
            <NavItem eventKey={3} componentClass={Link} href="/news" to="/news">
              News
            </NavItem>
  
          </Nav>
  
        </Navbar.Collapse>

      </Navbar>
    )
  }
} 
nav.navbar, .navbar-default {
    background-color: #2892D7 !important;
    margin-bottom: 0;
    margin:0;
    padding:0;
  }
  
  .navbar-default {
    background-image: none;
    border: none;
    border-radius: 5px;
    margin:0;
    padding:0;
  }
  
  .navbar-default .navbar-nav > li > a {
    color: white;
    margin-bottom: 0;
    position: relative;
    display: block;
    margin:0;
    padding:0;
  }
  
  .navbar-default .navbar-brand {
    color: white;
    margin-bottom: 0;
    margin:0;
    padding:0;
  }
  
  .navbar-default .navbar-toggle {
    border-color: white;
    margin-bottom: 0;
    margin:0;
    padding:0;
  }
  
  .navbar-default .navbar-toggle .icon-bar {
    background-color: white;
    margin:0;
    padding:0;
  }
  
  .navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover {
    background-color: transparent;
    margin-bottom: 0;
    margin:0;
    padding:0;
  }
  
  .navbar-default .navbar-brand:focus, .navbar-default .navbar-brand:hover {
    color: white;
    background-color: transparent;
    margin-bottom: 0;
    margin:0;
    padding:0;
  }
  
  .navbar-default .navbar-nav>li>a:focus, .navbar-default .navbar-nav>li>a:hover {
    color: white;
    background-color: transparent;
    margin-bottom: 0;
    margin:0;
    padding:0;
  }
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

Try flex-direction: row, it seems to be the only solution that works for me.


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

...