【发布时间】:2018-03-22 18:45:21
【问题描述】:
我在一个包装器元素中有一系列 3 个 SVG 元素,并且我使用 CSS 变换将此包装器旋转了 -90 度。
我正在尝试获取它,以便将黄色包含块固定在屏幕左侧,这样我就可以更改这个黄色包装器离左侧多远(% 或 vw)。
我减小了黄色包装元素的大小,以便更容易发现问题。黄色包装纸必须像现在一样保持垂直居中。
我这辈子都不能让它一直靠左——这种转变似乎让一切变得更加困难。我需要它,以便即使调整窗口大小,它也会从最左边保持一个设定的百分比(或 vw) - 为了论证,说 5% / 5vw。
P.S 我使用 SVG 文本是因为它是剪辑路径动画的一部分,但我已删除此代码以使内容更易于阅读。
Codepen:https://codepen.io/emilychews/pen/qojZae
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
position: relative;
}
#wrapper {
display: flex;
width: 25%;
justify-content: center;
background: yellow;
transform: rotate(-90deg);
position: absolute;
}
#wrapper svg {margin: 1rem}
text {font-size: 1rem}
<!-- THIS IS THE YELLOW BLOCK CONTAINING THE SVG ELEMENTS -->
<div id="wrapper">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="120" height="40" viewBox="0 0 120 40">
<rect class="masker" x="0" y="0" width="120" height="40" fill="red" />
<text x="16" y="25" fill="white">Some Text 1</text>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="120" height="40" viewBox="0 0 120 40">
<rect class="masker" x="0" y="0" width="120" height="40" fill="red" />
<text x="16" y="25" fill="white">Some Text 2</text>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="120" height="40" viewBox="0 0 120 40">
<rect class="masker" x="0" y="0" width="120" height="40" fill="red" />
<text x="16" y="25" fill="white">Some Text 3</text>
</svg>
</div>
【问题讨论】:
-
你的问题是什么?
标签: html css rotation alignment transform