[英]How to control the width and height of a svg element
I created a div wrapper with custom width and height and then put the SVG inside the wrapper but the width and height are not being modified, how can I control the width and height in this case?我创建了一个具有自定义宽度和高度的 div 包装器,然后将 SVG 放在包装器内,但宽度和高度没有被修改,在这种情况下如何控制宽度和高度?
export const SvgWrapper = styled.div`
width: ${(props) => props.width && props.width};
height: ${(props) => props.height && props.height};
padding-bottom: ${(props) => props.paddingBottom && props.paddingBottom};
`;
As in normal CSS, you need to target the SVG using CSS selector, you currently applying styles for div
element only.与普通 CSS 一样,您需要使用 CSS 选择器来定位 SVG 选择器,您当前仅应用
div
元素
export const SvgWrapper = styled.div`
svg {
width: ${(props) => props.width};
height: ${(props) => props.height };
padding-bottom: ${(props) => props.paddingBottom};
}
`;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.