2017-10-03 7 views
1

私はChromeで正しくレイアウトされた簡単なテーブルを持っています。しかし、IE11では、祖先要素がdisplay: flexのときにレイアウトが壊れます。祖先に表示されている場合、IE11テーブルレイアウトが壊れます。フレックス

ページの下部にある入力ボックスは、テーブルヘッダーの下部から10pxにする必要があります。これを行うには、ヘッダボックスのテキストにmargin-bottomを設定して、入力ボックス(フィルタ)用のスペースを確保してから、position:relativeの要素をアンカーするth要素の下部に配置します。すべてのヘルプは高く評価され https://codepen.io/nfknight/pen/KXyKdw

:ここ

はリンクです!あるいは、固定されたフィルター要素で可変高さのヘッダーテキストを達成する方法に関する他のアイデアがあるかどうか不思議です。 header-text要素とfilter要素は両方とも兄弟でなければなりません。

+0

フレキシボックスが唯一持っている[**部分的にサポート**](http://caniuse.com/#searchスニペット=フレックス) –

答えて

1

フレックスの祖先には問題ありません。それを削除しても、IE11やChromeでは違いはありません。それは絶対的な位置付けのレンダリングの違いのようです。

問題を回避するには、列をフレックスコンテナにすることができます。

revised codepen

.flexAncestor { 
 
    display: flex; 
 
} 
 

 
tr { 
 
    display: flex;  /* gives full height to children */ 
 
    height: 250px;  /* for demo only */ 
 
} 
 

 
.col1 { 
 
    display: inline-flex; 
 
    flex-direction: column; 
 
    width: 100px; 
 
    background: pink; 
 
} 
 

 
.col2 { 
 
    display: inline-flex; 
 
    flex-direction: column; 
 
    width: 100px; 
 
    background: lightblue; 
 
} 
 

 
.ui-column-title { 
 
    margin: auto;  /* flex auto margin; see below */ 
 
} 
 

 
.ui-column-filter { 
 
    align-self: center; 
 
    margin-bottom: 10px; 
 
    width: calc(100% - 15px); 
 
}
<div class="flexAncestor"> 
 
    <div class="tableContainer"> 
 
    <table class="testDataTable"> 
 
     <thead> 
 
     <tr> 
 
      <th class="col1"> 
 
      <span class="ui-column-title">id</span> 
 
      <input class="ui-column-filter" type="text" /> 
 
      </th> 
 
      <th class="col2"> 
 
      <span class="ui-column-title">Wrapping column header inside flex ancestor throws layout off in IE11 </span> 
 
      <input class="ui-column-filter" type="text" /> 
 
      </th> 
 
     </tr> 
 
     </thead> 
 
    </table> 
 
    </div> 
 
</div>

ここフレックスauto余白の詳細情報:

+1

私は、その房がそれをよく説明しているので、房として閉めることに決めました。それでも、私は見つけた解決策で答えました。それは偽装には存在せず、あなたのために+1しました。 – LGSon

+0

私がコメントアウトした場合:祖先のフレックス、問題は存在しません。 codepenはIEで常に自動的にリロードされないように見えることに注意してください。 –

1

Aをこの中


:sが、それがここにも記述されているテーブル要素にposition: relativeの効果は未定義であるという事実に基づいており、それが関連フレキシボックスされていない、言及しますケースでは、height: 100%をスタック上に固定すると絶対位置問題が解決されることが分かります。このルールを追加すると、IEでも同様に動作します。

.tableContainer, table, thead, tr, th { height: 100% } 

のSrc:https://davidwalsh.name/table-cell-position-absolute

スタックは

.flexAncestor { 
 
    display: flex; 
 
} 
 

 
.tableContainer { 
 
    flex: 1 0 auto; /* not sure if needed. */ 
 
} 
 

 
.tableContainer, table, thead, tr, th {   /* added */ 
 
    height: 100% 
 
} 
 

 
.ui-column-title { 
 
    margin-bottom: 100px; 
 
    display: inline-block; 
 
    white-space: normal; 
 
} 
 

 
.ui-column-filter { 
 
    position: absolute; 
 
    bottom: 10px; 
 
    left: 5px; 
 
    width: calc(100% - 15px); 
 
} 
 

 
.testDataTable th { 
 
    position: relative; 
 
} 
 

 
.col1 { 
 
    width: 100px; 
 
    background: pink; 
 
} 
 

 
.col2 { 
 
    width: 100px; 
 
    background: lightblue; 
 
}
<div class="flexAncestor"> 
 
    <div class="tableContainer"> 
 
    <table class="testDataTable"> 
 
     <thead> 
 
     <tr> 
 
      <th class="col1"> 
 
      <span class="ui-column-title">id</span> 
 
      <input class="ui-column-filter" type="text" /> 
 
      </th> 
 
      <th class="col2"> 
 
      <span class="ui-column-title">Wrapping column header inside flex ancestor throws layout off in IE11 </span> 
 
      <input class="ui-column-filter" type="text" /> 
 
      </th> 
 
     </tr> 
 
     </thead> 
 
    </table> 
 
    </div> 
 
</div>

+0

私が表示するコメント:祖先のフレックス、問題は存在しません。 codepenはIEで常に自動的にリロードされないように見えることに注意してください。高さを追加する:100%チェーンがcodepenの例で動作するようですが、私のアプリケーションでは動作しません。だから私はまだ問題がどこにあるのかを突き止めている。 –

+0

@ NateK投稿したコードが実際のもののサブセットでない場合は、2つの方法がありましたので、それ以上のことはできません。また、Codepenの 'display:flex'を削除すると、まだ動作しません。これはFlexboxとは何の関係もないことを証明しています。これも私の答えの最初の部分で説明しました。 – LGSon

関連する問題