css背景图像和背景颜色的最大宽度
我有一个css类,它有一个背景图像。我想将背景图像的最大宽度固定为1024px,并在浏览器超出该宽度时使用背景色进行渲染。我有办法做到吗 现在,我有css背景图像和背景颜色的最大宽度,css,Css,我有一个css类,它有一个背景图像。我想将背景图像的最大宽度固定为1024px,并在浏览器超出该宽度时使用背景色进行渲染。我有办法做到吗 现在,我有 background-size: cover; 而且,它会使图像高度失真超过1024px .imageform { width: 100%; display: inline-block; background: url("http://i.imgur.com/FPmyviO.jpg") no-repeat; -webkit-background-
background-size: cover;
而且,它会使图像高度失真超过1024px
.imageform {
width: 100%;
display: inline-block;
background: url("http://i.imgur.com/FPmyviO.jpg") no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-color: #000;
}
jsFIDLE:您必须更改
background-size:1024px;
而ypu却错过了
background-repeat: no-repeat;