Skip to content

Instantly share code, notes, and snippets.

@willwei
Last active January 2, 2016 19:09
Show Gist options
  • Save willwei/8348036 to your computer and use it in GitHub Desktop.
Save willwei/8348036 to your computer and use it in GitHub Desktop.
IE下使用filter实现纯色背景半透明

IE滤镜采用AARRGGBB(16进制)进行排列,AA位值也为 00-FF,也就是说10进制需要转成16进制 计算规则 10进制值*256/100然后再转16进制,就是说如果设置0.4的透明度40*256/100 = 102.4转16进制为66

  .rgba .test{ 
    background:rgba(255,255,255,.4); 
    background:none\9; 
    filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr=#66FFFFFF,endColorStr=#66FFFFFF);
  }

IE 9下由于两个属性都生效而叠加效果,所以一下hack .rgba_with_lastchild .test:last-child{ background:rgba(255,255,255,.4); filter:none;}

IE hack

.select {
    background-color:red\0;  /* ie 8/9*/
    background-color:blue\9\0;  /* ie 9*/
    *background-color:#dddd00;  /* ie 7*/
    _background-color:#CDCDCD;  /* ie 6*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment