【发布时间】:2019-03-10 08:36:39
【问题描述】:
我在页面上有一个按钮,其内容显示类似“我是一个按钮>”按钮中的侧胡萝卜符号设置为 :after 来自该按钮上的类的伪类中的 SVG 背景图像.
我希望内容编辑器能够通过 CMS 中的 HEX 颜色选择器更改文本和 SVG 的颜色。根据他们的选择,我目前正在将样式标签附加到按钮上。
我可以毫无问题地更改文本颜色,但我一直在尝试根据他们对样式标签的选择/更新来找出更改 SVG 填充颜色的方法。
我希望能够直接使用样式标签调整颜色,或者以某种方式将 HEX 值传递到我的 SASS 混合中。有没有办法做到这一点?也可以接受其他想法(理想情况下只有 CSS)来实现这一点。谢谢!
HTML:
<a href="#" target="_blank" class="btn" style="color: #E47B8E">I am a button</a>
SASS:
@mixin btn($bgColor: $stdBlue, $radius: 5px, $borColor: transparent, $display: inline-flex, $padding: 15px 40px, $fontSize: 0.88em, $weight: normal, $decorate: none, $color: white, $transform: uppercase, $borderStyle: solid) {
background-color: $bgColor;
border-radius: $radius;
border-color: $borColor;
display: $display;
padding: $padding;
font-size: $fontSize;
font-weight: $weight;
border-style: $borderStyle;
text-decoration: $decorate;
color: $color;
text-transform: $transform;
&:hover {
cursor: pointer;
}
&:after {
content: '';
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6.799 10.477"><path data-name="Path 226" d="M6.8 5.238l-5.24 5.238L0 8.916l3.678-3.678L0 1.56 1.56 0z" fill="#fff"/></svg>');
width: 7px;
background-repeat: no-repeat;
background-position: center;
margin-left: 5px;
}
}
.btn {
@include btn;
}
【问题讨论】:
标签: html css svg sass content-management-system