【问题标题】:Can I change the color of SVG fill or stroke?我可以更改 SVG 填充或描边的颜色吗?
【发布时间】:2019-12-12 00:39:34
【问题描述】:

我正在开发一个 Wordpress 模板,页脚中有一些社交媒体图标。我有一些用于图标的 SVG,但我希望能够通过我的主题选项页面(来自 Redux 框架)更改该 SVG 的颜色。我知道我可以为颜色创建一个字段,但我需要专门更改图标中的填充或描边。有办法吗?

我想创建这样的东西,但这似乎不适用于“描边”和“填充”之类的东西。

Redux::setSection( $opt_name, array(
    'title'      => 'icons',
    'id'         => 'social-icons',
    'subsection' => true,
    'fields'     => array(
        array(
            'id'       => 'facebook-icon-color',
            'type'     => 'color',
            'title'    => 'facebook-icon color', 
            'default'  => '#000000',
            'transparent' => false,
            'output' => array(
                'fill' => '.facebook-icon > svg > g',
            ),
            'validate' => 'color',
        ),
    ),
) );

【问题讨论】:

  • 您可以将fill="currentColor"设置为svg代码的路径。所以它采用它的父级颜色
  • 寻求代码帮助的问题必须包含重现它所需的最短代码在问题本身中最好在Stack Snippet 中。见How to create a Minimal, Reproducible Example
  • 我更新了我的问题,希望这能让事情更清楚。

标签: css svg redux-framework


【解决方案1】:

<path style="fill: yourcolor">

【讨论】:

    猜你喜欢
    • 2013-03-18
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    • 2014-08-11
    相关资源
    最近更新 更多