首页 > 解决方案 > React js语义菜单项在中心

问题描述

您好,我无法将我的内容放在此 div 的中心

代码: https ://codesandbox.io/s/hungry-https-c5432

我试图将内联显示放在 h5 上,但它仍然无法正常工作

<div className="App">
  <Menu
    className="borderless"
    style={{ width: "240px", height: "100vh" }}
    vertical
  >
    <Menu.Item className="logo">
      <Image src={logo} style={{ width: "50px", height: "50px" }} />
      <h5>E M A S A</h5>
      <Divider style={{ color: "#000 !important" }} />
    </Menu.Item>
  </Menu>
</div>

CSS:

.ui.menu {
  border-radius: 0px !important;
  border: 0px !important;
  box-shadow: none !important;
  background-color: #252631 !important;
}
.ui.menu .item {
  padding: 8px !important;
}
r {
  margin-bottom: 0 !important;
}r {
  margin-bottom: 0 !important;
}

标签: cssreactjssemantic-ui

解决方案


为了使img居中对齐,您可以添加 margin: 0 auto; display: block;

并为对齐文本h5您可以添加 text-align: center;

检查此链接:https ://codesandbox.io/embed/sweet-glitter-9toif?fontsize=14&hidenavigation=1&theme=dark


推荐阅读