2011-10-17 12 views
5

Internet Explorer 8以下でローテーションに問題があります。 親divを回転させることはできますが、子(絶対配置された)は親と一緒に回転しません。私は子供を絶対的な位置に置かないと、正しい回転をします。ここで回転と位置:絶対(IE8以下)

は私のコードは、私は緑のdivが同じ回転を持つことを希望しますが、IE8でこのコードを表示すると、これは結果

enter image description here

ある

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 


<style> 
    .parent 
    { 
     background-color: #f00; 
     position: absolute; 
     top: 300px; 
     left: 300px; 
     width: 500px; 
     height: 500px; 

     filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476, sizingMethod='auto expand'); //45deg 
    } 

    .child 
    { 
     background-color: #0f0; 
     position: absolute; 
     top: 150px; 
     left: 150px; 
     width: 300px; 
     height: 300px; 
    } 


</style> 

</head> 

<body> 

<div class="parent"> 
    This is the parent 
    <div class="child"> 
     This is the child 
    </div> 
</div> 



</body> 
</html> 

です赤いdiv。

ありがとうございます!

+0

ちょうど好奇心から、なぜあなたはdivを回転していますか?私はそれのための使用を発見したことがない、私はあなたの動機だけで興味があります。 – FreeSnow

+0

私はpreziプレゼンテーションのように見えるサイトを作る必要があります:)。 http://prezi.com/ – Vinzcent

+0

ああ、クールなアイデア。うーん、幸運:) – FreeSnow

答えて

1

回避策を頭に上記挿入:

:任意の子絶対配置要素に回転を適用するためにクラスを使用します

CSS:

.rotate { 
     filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476, sizingMethod='auto expand'); //45deg 
} 

HTML:

<div class="parent rotate"> 
    This is the parent 
    <p class="child rotate"> 
     This is the child 
    </p> 
</div> 
+0

これは動作しますが、親への子の位置は回転がないときと同じではありません。 – Vinzcent

+2

親に任意の値を持つ 'z-index'を追加すると問題が解決するはずです。ここにある:http://stackoverflow.com/questions/3055383/dximagetransform-matrix-absolutely-position-child-elements-not-rotating-in-ie-8/6268206#6268206 – achairapart

-1

IE8のバグ。

これは、この問題を解決するための簡単かつ効果的な方法です:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />