Sass/Compass - Convert Hex, RGB, or Named Color to RGBA

前端 未结 5 2220
暖寄归人
暖寄归人 2020-12-04 14:59

This may be Compass 101, but has anyone written a mixin which sets the alpha value of a color? Ideally, I would like the mixin to take any form of color definition, and app

5条回答
  •  死守一世寂寞
    2020-12-04 15:41

    I use the rgbapng compass plugin

    rgbapng is a Compass plugin for providing cross-browser* compatible RGBA support. It works by creating single pixel alpha-transparent PNGs on the fly for browsers that don't support RGBA. It uses the pure Ruby ChunkyPNG library resulting in hassle-free installation and deployment.

    Install

    gem install compass-rgbapng
    

    Usage

    @include rgba-background(rgba(0,0,0,0.75));
    

    Compiles to:

    background: url('/images/rgbapng/000000bf.png?1282127952');
    background: rgba(0, 0, 0, 0.75);
    

提交回复
热议问题