显示ReactBootstrap Navbar内联

时间:2018-04-16 17:53:13

标签: reactjs react-bootstrap mdbootstrap

我正在建立一个反应网站,我为Navbar和Carousel应用了Reactbootstrap。对于Footer MdBootstrap。

我遇到的问题是我的Navbar没有显示为内嵌,并且在导航栏和Carousel上左右有一个填充。

有人可以帮我解决这个问题吗?

这是我的CustomNavbar.jsx和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>
    )
  }
} 
&#13;
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;
  }
&#13;
&#13;
&#13;

这是它的样子: https://imgur.com/8B13iB6

1 个答案:

答案 0 :(得分:0)

尝试flex-direction: row,它似乎是唯一适用于我的解决方案。