将汉堡菜单移至右侧react-burger-menu

时间:2020-03-30 11:01:17

标签: javascript html css reactjs

我有一个使用react-burger-menu组件的burger菜单组件,它可以正常工作,但是我希望它移至页面的右侧并从右侧打开它。我在CSS中尝试过right:0和float:right,并尝试更改位置系统,但要么不移动,要么样式被破坏。如何将完全相同的菜单向右移动?

export default props => {
  return (
  // Pass on our props
    <Menu {...props}>
      <a className='menu-item' href='/'>
          Home
      </a>

      <a className='menu-item' href='/burgers'>
          Burgers
      </a>

      <a className='menu-item' href='/pizzas'>
          Pizzas
      </a>

      <a className='menu-item' href='/desserts'>
          Desserts
      </a>
    </Menu>
  )
}

html,
body {
  margin: 0;
}

#App {
  font-family: sans-serif;
  height: 100vh;
}

#page-wrap {
  text-align: center;
  overflow: auto;
}

.bm-item {
  display: inline-block;
  text-decoration: none;
  margin-bottom: 10px;
  color: #d1d1d1;
  transition: color 0.2s;
}


.bm-item:hover {
  color: white;
}


.bm-burger-button {
  position: fixed;
  width: 36px;
  height: 30px;
  left: 36px;
  top: 36px;
  /* right: 0; */
  /* float: right; */
}


.bm-burger-bars {
  background: #373a47;
}


.bm-cross-button {
  height: 24px;
  width: 24px;
}


.bm-cross {
  background: #bdc3c7;
}


.bm-menu {
  background: #373a47;
  padding: 2.5em 1.5em 0;
  font-size: 1.15em;
}

.bm-morph-shape {
  fill: #373a47;
}


.bm-item-list {
  color: #b8b7ad;
}


.bm-overlay {
  background: rgba(0, 0, 0, 0.3);
}

and:

class HRPanel extends Component {
  render () {
    return (
      <div id='App'>
        <SideBar pageWrapId='page-wrap' outerContainerId='App' />
        <div id='page-wrap'>

        </div>
      </div>
    )
  }
}

export default HRPanel

关于如何解决此问题的任何想法?

1 个答案:

答案 0 :(得分:0)

固定样式如下:

.bm-burger-button {
  position: relative;
  width: 36px;
  height: 30px;
  right: 36px;
  top: 36px;
  /* right: 0; */
  float: right;
}