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

5
我有一个使用 react-burger-menu 组件的汉堡菜单,并且它工作正常,但我想把它移到页面的右侧,并从右侧打开。 我在 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

有没有任何想法来修复这个问题?

2个回答

2

默认情况下,菜单从左侧打开。若要从右侧打开,请使用 right 属性。它只是一个布尔值,因此不需要指定值。然后使用 CSS 设置按钮的位置。

<Menu right />

并且

 .bm-burger-button {
    right: 0%;
  }

1
修复类似以下的样式:
.bm-burger-button {
  position: relative;
  width: 36px;
  height: 30px;
  right: 36px;
  top: 36px;
  /* right: 0; */
  float: right;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接