我试图证明一个线框可以响应地工作,这样列表项目1-4显示:块在移动,在桌面上1,3,5显示相互内联。
我只在Chrome中遇到了一个奇怪的错误,即元素1,3,5在调整到小断点后不会重新进行内联。
演示:http://jsfiddle.net/n0ocqf2w/3/
全屏:https://jsfiddle.net/n0ocqf2w/3/embedded/result/
stackoverflow让我发布带有jsfiddle链接的代码,下面是我们使用的样式:
* {
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
ul {
margin: 50px 0 0 0;
padding: 0;
font-size: 0;
white-space: nowrap;
}
li {
display: block;
margin: 0;
padding: 10px 50px;
height: 40px;
background: red;
font-size: 12px;
position: relative;
z-index: 2;
display: block;
width: 100%;
}
li:nth-child(1) {
background: red;
}
li:nth-child(2) {
background: pink;
}
li:nth-child(3) {
background: blue;
}
li:nth-child(4) {
background: lightBlue;
}
li:nth-child(5) {
background: green;
position: fixed;
top: 0;
right: 0;
width: 50%;
}
@media screen and (min-width:400px) {
body {
background: black;
}
ul {
margin: 0;
}
li {
display: inline-block;
width: 20%;
vertical-align: top;
}
li:nth-child(2) {
background: pink;
position: fixed;
top: 35px;
left: 0;
width: 100%;
z-index: 1;
opacity: .5;
}
li:nth-child(4) {
background: lightBlue;
position: fixed;
top: 45px;
left: 20px;
width: 100%;
z-index: 1;
opacity: .5;
}
li:nth-child(5) {
background: green;
position: relative;
width: 20%;
}
}在Chrome中复制的步骤:
经过一番挖掘,我发现了一个已经4年多没有修复过的非常老的bug:bug.cgi?id=53166
有人能确认一下这个是否可以修复吗?我真的希望上面链接中打开的bug在这里不存在,但是在调整大小后不应用媒体查询中显示属性的标准正好匹配:-(
干杯
发布于 2015-06-03 18:52:01
希望这能有所帮助。http://jsbin.com/bakujusaxu/1/edit?css,output
/*
SOLUTION HERE
The following elements are being treated as a "clearfix" type of thing, so when you re-size from "mobile" to "desktop" the fixed position elements are being treated as "block", as they happen to be intersected elements, it gives the stacked result...
*/
@media screen and (min-width:400px) {
li:nth-child(2),
li:nth-child(4) {
/*
The bug is a re-drawing bug. Not your fault, but the browser's.
The ideal solution, would be to set this to inline, but that doesn't work.
So you can set it to the following values:
none
flex
table
list-item
*/
display: flex;
}
}https://stackoverflow.com/questions/30627131
复制相似问题