我有一个如下所示的列表,在Firefox中,图像实际上与浏览器宽度一起缩放,但在Chrome中,当我调整图像大小时保持相同的大小,<li>
部分只填充空白区域。 See what I mean here
HTML
<ul>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
<li><img src="http://distilleryimage8.s3.amazonaws.com/23ddf3860e2911e29c2d22000a1e9e7e_6.jpg"></li>
</ul>
CSS
li img{
display: block;
height: auto;
width: 100%;
float: left;
}
@media screen and (min-width: 307px) and (max-width: 440px) {
li{
float:left;
width: 50%;
height: auto;
display: inline-block;
}
}
@media screen and (min-width: 440px) and (max-width: 480px) {
li{
float:left;
width: 50%;
height: auto;
display: inline-block;
}
}
@media screen and (min-width: 480px) and (max-width: 612px) {
li{
float:left;
width: 50%;
height: auto;
display: inline-block;
}
}
@media screen and (min-width: 612px) and (max-width: 767px) {
li{
float:left;
width: 33.3333%;
height: auto;
display: inline-block;
}
}
@media screen and (min-width: 768px) and (max-width: 901px){
li{
float:left;
width: 33.3333%;
height: auto;
display: inline-block;
}
}
@media screen and (min-width: 901px) and (max-width: 1024px) {
li{
float:left;
width: 25%;
height: auto;
display: inline-block;
}
}
/* Desktops and laptops ----------- */
@media only screen and (min-width : 1024px) and (max-width: 1079px){
li{
float:left;
width: 20%;
height: auto;
display: inline-block;
}
}
@media only screen and (min-width : 1079px) and (max-width: 1224px) {
li{
float:left;
width: 20%;
height: auto;
display: inline-block;
}
}
@media only screen and (min-width : 1224px) and (max-width: 1530px) {
li{
float:left;
width: 20%;
height: auto;
display: inline-block;
}
}
/* Large screens ----------- */
@media only screen and (min-width: 1530px) and (max-width : 1824px) {
li{
float:left;
width: 16.6666%;
height: auto;
display: inline-block;
}
}
/* Large screens ----------- */
@media only screen and (min-width : 1824px) {
li{
float:left;
width: 11.1111%;
height: auto;
display: inline-block;
}
}
答案 0 :(得分:0)
@-moz-document url-prefix() {
li img{
width: 100%;
max-width: 100%;
}
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
li img{
max-width: 100%;
}
}
结果我需要为firefox和chrome
的条件浏览器黑客添加max-width add