javascript

根据背景图片大小,来设置元素的宽,高

2019-10-09  本文已影响0人  天劫天罪

解决办法:less ,利用less里面高阶函数 image-with('path'),image-height('path')
例子: img大小 1200*300
div{

background:url('bg.png') center center no-repeat;

width:image-width('bg.png');

height:image-height('bg.png');

}

经过less编译后的css样式

div{

background:url('bg.png') center center no-repeat;

width:1200px;

height:300px;

}

上一篇 下一篇

猜你喜欢

热点阅读