【问题标题】:SVG is offset in navbarSVG 在导航栏中偏移
【发布时间】:2022-01-13 16:21:59
【问题描述】:

我正在用 ReactTS 制作我的网页。我做了一个导航栏,我想从 MUI Material Icons 添加一些 SVG。但我唯一的问题是 SVG 有点太高了:

Screenshot

已经尝试将位置设置为inherit,但也没有效果,这是CSS:

nav {
  position: fixed;
  display: block;
  margin: auto;
  top: 0;
  width: 100%;
  height: 50px;
  padding-left: 10px;
  font-size: calc(10px + 2vmin);
  background-color: #3e424d;
  color: white;
}

svg {
  position: inherit;
}

谁能帮帮我?我不擅长 CSS

【问题讨论】:

  • 很难说不知道 svgs 的高度。尝试添加 display:flex, align-items: center 到 svg
  • @Marshall ~~工作,但现在 SVG 在文本内,但高度现在是固定的!~~通过删除 position: inherit; 标签修复它!谢谢!

标签: javascript css reactjs


【解决方案1】:

感谢@Marshall,我可以通过添加来修复它:

display: flex;
align-items: center;

(也删除了position: inherit;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-27
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 2016-04-26
    相关资源
    最近更新 更多