SVG的PHP CSS控制 [英] PHP CSS control of SVG

查看:97
本文介绍了SVG的PHP CSS控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用CSS来控制.svg文件的颜色。我使用html来调用svg。我的页面上的颜色由.php控制(其他所有内容都在。我确定我必须错过一个步骤,因为我无法获取彩色php页面来控制svg。)

I am attempting to use CSS to control the colors of an .svg file. I use an html to call the svg. The colors on my page are controlled by .php (everything else is in . I am certain i must be missing a step as I am unable to get the color php page to control the svg.

<div class="headerPhoto">
    <img src="images/icon.svg">       
</div>










<rect class="iconRect" x="-7.7" y="-6.37" width="234.25" height="233.795" />
    <g>
        <path d="M119.575,125.577l-22.755,44.607l-71.538,-0.213l58.744,-115.155l35.549,70.761ZM46.732,156.877l42.041,0.125l16.054,-31.47l-20.891,-41.585l-37.204,72.93Z" style="fill:#383b40;"/>
        <path d="M199.718,169.971l-71.538,0.213l-22.755,-44.607l35.549,-70.761l58.744,115.155ZM120.173,125.532l16.054,31.47l42.041,-0.125l-37.204,-72.93l-20.891,41.585Z"/>
    </g>

    <path d="M240.789,48.355c0,-35.402 -28.742,-64.144 -64.144,-64.144l-128.29,0c-35.402,0 -64.144,28.742 -64.144,64.144l0,128.29c0,35.402 28.742,64.144 64.144,64.144l128.29,0c35.402,0 64.144,-28.742 64.144,-64.144l0,-128.29Z" style="fill:none;stroke-width:47.37px;stroke:#fff;"/>

<?php 
  header('content-type: text/css;');

  $color1 = $colorDarkGreen;
  $color2 = $colorWhite;
  $color3 = $colorGray;
?>

.iconRect {fill:<?=$color2?>;}

我可以直接更改.svg文件中的样式值,但无法使外部样式表工作。

I am able to directly change the style values in the .svg file, but can't get the external stylesheets to work.

我不确定我

推荐答案

大多数WordPress主题都是这样工作的,其中style属性中的PHP变量回声PHP / HTML

Most WordPress themes work like this, where the PHP variable echos in the style attribute of the PHP/HTML

<?php

  $colorWhite = #efefef;

?>

<element style='color: <?php echo $colorWhite ?>;'></element>

并构建HTML

<element style='color: #efefef;'></element>

您无法使用JavaScript或PHP或...好 - 除了CSS中的CSS外, (你可以用预处理器做一些功能性的东西),但它仍然会输出到CSS。

You can't use JavaScript or PHP or ... well - anything but CSS in CSS. ( you can do some functional stuff with a pre-processor ) but it still gets output to CSS.

这篇关于SVG的PHP CSS控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆