yii\helpers\BaseHtml::addCssStyle PHP Метод

addCssStyle() публичный статический Метод

If the options already contain a style element, the new style will be merged with the existing one. If a CSS property exists in both the new and the old styles, the old one may be overwritten if $overwrite is true. For example, php Html::addCssStyle($options, 'width: 100px; height: 200px');
См. также: removeCssStyle()
См. также: cssStyleFromArray()
См. также: cssStyleToArray()
public static addCssStyle ( array &$options, string | array $style, boolean $overwrite = true )
$options array the HTML options to be modified.
$style string | array the new style string (e.g. `'width: 100px; height: 200px'`) or array (e.g. `['width' => '100px', 'height' => '200px']`).
$overwrite boolean whether to overwrite existing CSS properties if the new style contain them too.
    public static function addCssStyle(&$options, $style, $overwrite = true)
    {
        if (!empty($options['style'])) {
            $oldStyle = is_array($options['style']) ? $options['style'] : static::cssStyleToArray($options['style']);
            $newStyle = is_array($style) ? $style : static::cssStyleToArray($style);
            if (!$overwrite) {
                foreach ($newStyle as $property => $value) {
                    if (isset($oldStyle[$property])) {
                        unset($newStyle[$property]);
                    }
                }
            }
            $style = array_merge($oldStyle, $newStyle);
        }
        $options['style'] = is_array($style) ? static::cssStyleFromArray($style) : $style;
    }