在css中,我们经常需要使用opacity
来设置某个dom的透明度,但是这属性在ie8中存在兼容性问题,我现在想写一个函数,方便同时兼容
.opacity(@num-opt) {
opacity: @num-opt;
filter: alpha(opacity = percentage(@num-opt)); //filter 过滤器 兼容IE678
}
具体调用时
.head-warp {
// height: 50px;
height: 50px;
position: fixed;
top: 0;
z-index: 2;
width: 100%;
// background-color: rgba(255, 255, 255, .9);
background-color: rgb(255, 255, 255);
// opacity: 0.9;
// filter:alpha(opacity=90);
.opacity(0.9);
.shadow(2,2,10,@color-holder);
.head-logo {
img {
height: 40px;
}
}
}
但是less编译的时候,一直报