有没有办法旋转文本输入?
I have to align a textbox and some text, at about 30 degrees, like this:
I would like it to work at least in IE and FF. Everything I found on the net deals with image rotation.
Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
没有好的跨浏览器解决方案。
最新的 Webkit 支持 CSS 转换,可以以简单的方式实现此类操作。
SVG 中的
理论上允许旋转 HTML,但它没有得到广泛支持(在支持的地方,它通常不完整且有错误)。我建议您更改页面设计。 尝试使用输入周围的边框和阴影的视觉技巧,使其看起来略有旋转。
我建议不要对 Javascript 或 Flash 进行黑客攻击。 浏览器的输入元素对于可用性非常重要。 您的黑客可能无法很好地使用密码管理器/自动填充、各种标准键盘快捷键、文本选择等。
There's no good cross-browser solution.
Latest Webkit supports CSS transformations, that allow such thing in straightforward way.
There's
<foreignContent>
in SVG that theoretically would allow to rotate HTML, but it's not widely supported (and where it's supported, it's usually incomplete and buggy).I suggest that you change design of the page. Try visual tricks with borders and shadows around the input that make it seem slightly rotated.
I advise against hacks in Javascript or Flash. Browser's input elements are important for usability. Your hacks may not play well with password managers/autofill, various standard keyboard shortcuts, text selection, etc.
你最好的选择可能是Flash。
Your best bet is probably Flash.
在当前浏览器上不完全支持,但(至少)在 FF3 和 IE7 上可以正常工作画布 HTML 元素。 canvas 元素是 HTML5 的一部分,允许对位图图像进行动态脚本化渲染。
Canvas 由 HTML 代码中定义的具有高度和宽度属性的可绘制区域组成。 JavaScript 代码可以通过类似于其他常见 2D API 的全套绘图函数来访问该区域,从而允许动态生成图形。
Mozilla 手册中的页面展示了如何在画布上绘制文本。 所有画布图形都可以应用
rotate(angle)
。 该示例使用旋转方法以圆形图案绘制形状:Not fully supported on current browsers, but works reasonably (at least) on FF3 and IE7, is the canvas HTML element. The canvas element is part of HTML5 and allows for dynamic scriptable rendering of bitmap images.
Canvas consists of a drawable region defined in HTML code with height and width attributes. JavaScript code may access the area through a full set of drawing functions similar to other common 2D APIs, thus allowing for dynamically generated graphics.
A page from the Mozilla Manual shows how to draw text on a canvas. All canvas graphics can have
rotate(angle)
applied. The example uses the rotate method to draw shapes in a circular pattern.:同意PEZ的观点。 我会使用 Flash。 但在 Safari 中,您可以使用 CSS3 转换来完成此操作。
Agree with PEZ. I would use Flash for this one. But in Safari you can use CSS3 transformations to accomplish this.
无论如何,我认为这只能在 CSS3 中完成,CSS3 还没有得到广泛的支持,无法使用(除非它是某种内部应用程序,你可以说需要特定的浏览器)。
Off the top of any head, I think this is something that you can only do in CSS3 which isn't widely supported enough to use yet (unless it's some kind of internal app where you can say that a certain browser is required).
尝试 css3
但这不适用于 IE
For IE 9+ (感谢 Michael Potter)
Try css3
But this will not work on IE
For IE 9+ (thanks to Michael Potter)