【发布时间】:2022-01-13 16:21:59
【问题描述】:
我正在用 ReactTS 制作我的网页。我做了一个导航栏,我想从 MUI Material Icons 添加一些 SVG。但我唯一的问题是 SVG 有点太高了:
已经尝试将位置设置为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