css - 如何定位来自 SVG 的 <use> 的 SVG 图像

标签 css svg css-position css-transforms

我有一个 SVG,它是一种包含 12 个字符的合影。 SVG 还包含这些 Angular 色在合影中的位置。每个字符都有一个 id .现在使用 SVG 的 <use> 我想在页面的另一部分重复使用这些单个字符。

像这样:

enter image description here

请注意上图左下方显示的头部。如您所见,定位不起作用。我已经尝试设置 top , left , position: absolute , translate(0, 0) -- 但没有成功。

实际上它应该是这样的: enter image description here

我设置了一个 codepen在哪里可以看到问题。有什么想法可以让它发挥作用吗?

最佳答案

添加这个样式

.st-infobox__img svg use {
    transform:  translate(-300px, -100px);
}

corrected codepen

关于css - 如何定位来自 SVG 的 <use> 的 SVG 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45237346/

相关文章:

css - 如果目录不在 ScrollView 中则显示 Div

jquery - 如何使用 CSS(jQuery SVG 图像替换)更改 SVG 图像的颜色?

html - 按固定像素数移动 SVG

html - 调整大小时页脚重叠内容

html - Chrome DevTools 中的响应式模拟是否始终准确?

javascript - 拉伸(stretch)和旋转 SVG 图像的特定部分

html - 无论表格中有两个输入框,提交按钮都不会对齐

html - IOS8 : whole page scrolls down when input in fixed footer gets focus

html - 为标题中的 block 着色

css - Bootstrap 相应地对齐选项卡内容