CSS 旋转& IE:绝对定位似乎打破了 IE
我正在尝试旋转各种文本块,使它们垂直定向,并将它们放置在图表上非常特定的位置,然后预览然后打印。 CSS 在 IE、FF、甚至 Opera 中可以很好地旋转文本。
但是当我尝试定位旋转元素时,IE 7 & 8(不担心 6)完全断裂并且元素保留在其原始位置。有什么办法解决这个问题吗?我确实需要对这些标签的位置进行像素控制。
HTMLCSS
<div class="content rotate">
<div id="Div1" class="txtblock">Ardvark Avacado<br />Awkward</div>
<div id="Div2" class="txtblock">Brownies<br />Bacteria Brussel Sprouts</div>
</div>
div.content {
position: relative;
width: 300px;
height: 300px;
margin: 30px;
border-top: black 4px solid;
border-right: blue 4px solid;
border-bottom: black 4px dashed;
border-left: blue 4px dashed; }
.rotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); }
.txtblock {
width: auto;
position: absolute;
}
#Div1 {
left:44px;
top:70px;
border:red 3px solid; }
#Div2 {
left:13px;
top:170px;
border:purple 3px solid; }
I'm trying to rotate a variety of text blocks so they are vertically oriented, and position them in very specific locations on a diagram which will be previewed and then printed. CSS rotates the text very nicely in IE, FF, even Opera.
But when I try to position a rotated element, IE 7 & 8 (not worried about 6) breaks completely and the element stays in its original location. Any way around this? I really need to-the-pixel control of where these labels are located.
HTML
<div class="content rotate">
<div id="Div1" class="txtblock">Ardvark Avacado<br />Awkward</div>
<div id="Div2" class="txtblock">Brownies<br />Bacteria Brussel Sprouts</div>
</div>
CSS
div.content {
position: relative;
width: 300px;
height: 300px;
margin: 30px;
border-top: black 4px solid;
border-right: blue 4px solid;
border-bottom: black 4px dashed;
border-left: blue 4px dashed; }
.rotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); }
.txtblock {
width: auto;
position: absolute;
}
#Div1 {
left:44px;
top:70px;
border:red 3px solid; }
#Div2 {
left:13px;
top:170px;
border:purple 3px solid; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这听起来像是我花了很多时间来解决的问题。我在 Paul Irish 的博客文章上留下了两条评论,详细介绍了我的发现。这是我写的:
...以及更多 CSS 旋转怪异现象需要报告:
尽管我的问题略有不同,但您可能会遇到类似的情况,两个内部 div 由父级旋转。值得一试。至少尝试将 .rotate 声明移至样式表的底部。
This sounds like an issue I spent a good deal of time with. I left two comments on Paul Irish's blog post detailing my findings. Here is what I wrote:
...and more CSS rotation weirdness to report:
Even though my issue was slightly different, you may be running into a similar situation with the two inner divs being rotated by the parent. It's worth a shot. At least try moving the .rotate delclaration to the bottom of the stylesheet.
尝试此代码:
您将该代码应用到了错误的元素。也作为其他人理解此 http://snook.ca/archives/html_and_css/ 的参考CSS 文本旋转
Try this code:
You're applying the code to the wrong element. Also as reference to others in understanding this http://snook.ca/archives/html_and_css/css-text-rotation
我发现如果将旋转放在 txtblocks 上而不是放在外部容器上,这会起作用。
演示
I find that this works if you put the rotations on the txtblocks, instead of on the outer container.
Demo