public function toCSS(CSSDocument $css, $selector)
    {
        if ($this->url) {
            $size = 'contain';
            $repeat = 'no-repeat';
            $positionHor = 'center';
            $positionVer = 'center';

            switch ($this->style) {
                case self::TYPE_STRETCH:
                    $size = '100% 100%';
                    break;
                case self::TYPE_TILE:
                    $repeat = 'repeat';
                    break;
                case self::TYPE_CENTER:
                    if (is_array($this->size)) {
                        $size = "{$this->size['width']}px {$this->size['height']}px";
                    } else {
                        $size = 'auto';
                    }
                    break;
                case self::TYPE_FILL:
                    $size = 'cover';
                    break;
            }

            if ($this->attachment) {
                $i = $this->attachment & 3;
                if ($i == 1) {
                    $positionHor = 'left';
                } else {
                    if ($i == 3) {
                        $positionHor = 'right';
                    }
                }
                $i = $this->attachment & 12;
                if ($i == 4) {
                    $positionVer = 'top';
                } else {
                    if ($i == 12) {
                        $positionVer = 'bottom';
                    }
                }
            }

            $css->addRule($selector, 'background-image', $css->getURLValue($this->url));
            $css->addRule($selector, 'background-repeat', $repeat);
            $css->addRule($selector, 'background-position', "$positionHor $positionVer");
            $css->addRule($selector, 'background-size', $size);
        }
        $css->addRule($selector, 'background-color', $css->getColorValue($this->color));
    }