如何将 270 度旋转的文本对齐到左上角?
这应该是一个你会想到的非常简单的问题。我有一个带有一些标题文本的框,我想将其旋转 -90 度。我希望它是绝对定位的,以便单词的末尾被轻推到左上角。我可以很容易地将其对齐到底部,但问题是,对于可变长度文本,在对齐到顶部时似乎不可能始终将其保留在容器内,因为诸如 {top: 0} 在转换之前对标题进行操作。就我的目的而言,这只需要在 Firefox 中工作。如果这是唯一的解决方案,我可以使用 javascript,但您可能会认为仅使用 CSS 即可完成。
This should be a very simple problem you would think. I have a box with some title text that I want to rotate -90 degrees. I would like it to be absolutely positioned so that the end of the word is nudged into the top left corner. I can get this to align to the bottom easily enough, but the problem is that with variable length text it seems impossible to have it consistently stay within the container when aligning to the top because things like {top: 0}
operate on the title before the transform. For my purposes this only needs work in Firefox. I can use javascript if that is the only solution, but you would think this could be done with just CSS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用
transform-origin
来调整变换点,并创造性地使用定位属性。http://jsfiddle.net/thirtydot/JxEfs/1/
CSS:< /strong>
HTML:
You should use
transform-origin
to adjust the transformation point, along with some creative use of positioning properties.http://jsfiddle.net/thirtydot/JxEfs/1/
CSS:
HTML:
没有权限也可以工作:100%
只需围绕左上角旋转 270 度,然后将其平移回新的 100% 宽度即可。
http://jsfiddle.net/zW7SP/
Can also work without right:100%
Just rotate 270 deg around left top and then translate it back at new 100% width.
http://jsfiddle.net/zW7SP/