简体   繁体   English

如何使react-burger-menu与Bootstrap网格一起使用?

[英]How do I get the react-burger-menu to work with bootstrap grid?

I'm trying to use react-burger-menu with bootstrap 3 grids. 我正在尝试使用带有bootstrap 3网格的react-burger-menu。 I want to have a row across the top of my page that has the burger menu in the upper left corner with the remainder of the row containing a page title, so I wrote: 我想在页面的顶部有一行,在左上角有burger菜单,其余部分包含页面标题,所以我这样写:

import React from 'react'
import { slide as ReactMenu } from 'react-burger-menu'

export default class Header extends React.Component {

  showAbout(event) {
    event.preventDefault()
    console.log("Version 0.0.1")
  }

  render() {
    return(
      <div className="container">
        <div className="row">
          <div className="col-lg-2">
            <ReactMenu>
              <a id="View" className="menu-item" href="/">View</a>
              <a onClick={ this.showAbout } className="menu-item--small" href="">About</a>
            </ReactMenu>
          </div>
          <div className="col-lg-10 h1">Permit and License Documents</div>
        </div>
      </div>
    )
  }
}

But what I get is: 但是我得到的是:

渲染结果

I thought I would use bootstrap grid to layout the horizontal spacing, but it is not working. 我以为我会使用自举网格来布置水平间距,但是它不起作用。 Is there a way to do this, or should I use something other than bootstrap Grids? 有没有办法做到这一点,还是我应该使用引导网格以外的其他方法? TIA. TIA。

It looks like that h1 class is applying some property that's overriding the col behavior. 看起来h1类正在应用一些属性来覆盖col行为。 It is also possible that you need to add the col class in addition to the col-lg-2 such that <div className='col col-lg-2' 还可能需要在col-lg-2之外添加col类,以使<div className='col col-lg-2'

Try: 尝试:

<div className="container">
        <div className="row">
          <div className="col col-lg-2">
            <ReactMenu>
              <a id="View" className="menu-item" href="/">View</a>
              <a onClick={ this.showAbout } className="menu-item--small" href="">About</a>
            </ReactMenu>
          </div>
// change here:
          <div className="col col-lg-10">
            <h1>Permit and License Documents</h1>
          </div>
        </div>
      </div>

Finally, make sure that you're col size is correct. 最后,请确保您的col大小正确。 try making it from md up. 尝试从md开始制作。 Example: <div className='col-md-2'></div> 示例: <div className='col-md-2'></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM