【发布时间】:2022-01-04 12:49:16
【问题描述】:
我有外部 svg:
<?xml-stylesheet type="text/css" href="../../css/style.css" ?>
<svg class="header__nav-icon" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M30.75 14.75H1.25C0.559625 14.75 0 15.1082 0 15.55C0 15.9918 0.559625 16.35 1.25 16.35H30.75C31.4404 16.35 32 15.9918 32 15.55C32 15.1082 31.4404 14.75 30.75 14.75Z" fill="#444444"/>
<path d="M30.75 4.75H1.25C0.559625 4.75 0 5.10816 0 5.55C0 5.99184 0.559625 6.35 1.25 6.35H30.75C31.4404 6.35 32 5.99184 32 5.55C32 5.10816 31.4404 4.75 30.75 4.75Z" fill="#444444"/>
<path d="M30.75 24.75H1.25C0.559625 24.75 0 25.1082 0 25.55C0 25.9918 0.559625 26.35 1.25 26.35H30.75C31.4404 26.35 32 25.9918 32 25.55C32 25.1082 31.4404 24.75 30.75 24.75Z" fill="#444444"/>
</svg>
如果我设置默认高度值height="30px" 一切正常,但在这种情况下我无法在 css 中设置大小属性
我有下一个 css,但它不起作用并且 svg 保持 0x0 大小:
.header__nav-icon {
height: 30px;
}
@media screen and (max-width: 380px) {
.header__nav-icon {
height: 24px;
}
}
有什么问题?
【问题讨论】: