flex 布局在 webkit(chrome/safari) 与 moz(firefox) 上的行为不正确
flex layout behaving incorrectly on webkit(chrome/safari) vs moz(firefox)
我正在使用 flex,它在 mozilla(-moz-) 和 chrome/safari(-webkit-)
上显示不正确的行为
使用 mozilla tutorial 了解弹性布局
/** {
border: solid;
border-width: 0 1px;
}*/
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.tab3 {
display: flex;
display: -webkit-flex;
flex-flow: row;
-webkit-flex-flow: row;
-moz-flex-flow: row;
width: 100%;
height: 100%;
}
.left-pane {
display: flex;
display: -webkit-flex;
flex: none;
-webkit-flex: none;
-moz-flex: none;
flex-flow: column;
-webkit-flex-flow: column;
-moz-flex-flow: column;
width: 150px;
height: 100%;
min-width: 150px;
background-color: red;
}
.content-list {
flex: auto;
-webkit-flex: auto;
-moz-flex: auto;
background-color: lightgreen;
}
.left-bottom-content {
flex: none;
-webkit-flex: none;
-moz-flex: none;
height: 50px;
background-color: orange;
}
.right-pane {
display: flex;
display: -webkit-flex;
flex-flow: column;
-webkit-flex-flow: column;
-moz-flex-flow: column;
flex: auto;
-webkit-flex: auto;
-moz-flex: auto;
height: 100%;
min-width: 300px;
}
.right-pane-content {
display: flex;
display: -webkit-flex;
flex-flow: row;
-webkit-flex-flow: row;
-moz-flex-flow: row;
flex: auto;
-webkit-flex: auto;
-moz-flex: auto;
width: 100%;
}
.right-first {
display: flex;
display: -webkit-flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 30%;
height: 100%;
background-color: green;
}
.right-second {
display: flex;
display: -webkit-flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 70%;
height: 100%;
background-color: blue;
}
.right-bottom-content {
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 100%;
height: 100px;
background-color: yellow;
}
<div class="tab3">
<div class="left-pane">
<div class="content-list">
<h3>4</h3>
</div>
<div class="left-bottom-content">
<h3>5</h3>
</div>
</div>
<div class="right-pane">
<div class="right-pane-content">
<div class="right-first cell-3">
<h3 class="right-heading">8</h3>
</div>
<div class="right-second cell-4">
<h3 class="some-heading">9</h3>
</div>
</div>
<div class="right-bottom-content">
<h3>7</h3>
</div>
</div>
</div>
截图以便更好地理解:
火狐显示
Chrome显示
谢谢
不要在使用display: flex
的class中使用height: 100%
,你应该把height: inherit
给.right-first
和right-second
class:
.right-first {
display: flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 30%;
height: inherit;
background-color: green;
}
.right-second {
display: flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 70%;
height: inherit;
background-color: blue;
}
我正在使用 flex,它在 mozilla(-moz-) 和 chrome/safari(-webkit-)
上显示不正确的行为使用 mozilla tutorial 了解弹性布局
/** {
border: solid;
border-width: 0 1px;
}*/
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.tab3 {
display: flex;
display: -webkit-flex;
flex-flow: row;
-webkit-flex-flow: row;
-moz-flex-flow: row;
width: 100%;
height: 100%;
}
.left-pane {
display: flex;
display: -webkit-flex;
flex: none;
-webkit-flex: none;
-moz-flex: none;
flex-flow: column;
-webkit-flex-flow: column;
-moz-flex-flow: column;
width: 150px;
height: 100%;
min-width: 150px;
background-color: red;
}
.content-list {
flex: auto;
-webkit-flex: auto;
-moz-flex: auto;
background-color: lightgreen;
}
.left-bottom-content {
flex: none;
-webkit-flex: none;
-moz-flex: none;
height: 50px;
background-color: orange;
}
.right-pane {
display: flex;
display: -webkit-flex;
flex-flow: column;
-webkit-flex-flow: column;
-moz-flex-flow: column;
flex: auto;
-webkit-flex: auto;
-moz-flex: auto;
height: 100%;
min-width: 300px;
}
.right-pane-content {
display: flex;
display: -webkit-flex;
flex-flow: row;
-webkit-flex-flow: row;
-moz-flex-flow: row;
flex: auto;
-webkit-flex: auto;
-moz-flex: auto;
width: 100%;
}
.right-first {
display: flex;
display: -webkit-flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 30%;
height: 100%;
background-color: green;
}
.right-second {
display: flex;
display: -webkit-flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 70%;
height: 100%;
background-color: blue;
}
.right-bottom-content {
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 100%;
height: 100px;
background-color: yellow;
}
<div class="tab3">
<div class="left-pane">
<div class="content-list">
<h3>4</h3>
</div>
<div class="left-bottom-content">
<h3>5</h3>
</div>
</div>
<div class="right-pane">
<div class="right-pane-content">
<div class="right-first cell-3">
<h3 class="right-heading">8</h3>
</div>
<div class="right-second cell-4">
<h3 class="some-heading">9</h3>
</div>
</div>
<div class="right-bottom-content">
<h3>7</h3>
</div>
</div>
</div>
截图以便更好地理解:
火狐显示
Chrome显示
谢谢
不要在使用display: flex
的class中使用height: 100%
,你应该把height: inherit
给.right-first
和right-second
class:
.right-first {
display: flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 30%;
height: inherit;
background-color: green;
}
.right-second {
display: flex;
flex-flow: column;
flex: none;
-webkit-flex: none;
-moz-flex: none;
width: 70%;
height: inherit;
background-color: blue;
}