设置SVG图片的颜色-color:#f50

让svg图片的颜色跟随元素的color值变化:

  • 在path/react等标签中将fill改为fill=“currentColor”
<?xml version="1.0" encoding="UTF-8"?>
<svg width="30px" height="30px" viewBox="0 0 30 30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
    <defs>
        <linearGradient x1="50%" y1="50%" x2="100%" y2="75.5102041%" id="linearGradient-1">
            <stop stop-color="#FFFFFF" stop-opacity="0" offset="0%"></stop>
            <stop stop-color="#FFFFFF" stop-opacity="0.803501796" offset="100%"></stop>
        </linearGradient>
    </defs>
    <g id="页面-2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="菜单栏" transform="translate(-52.000000, -51.000000)">
            <g id="编组-3" transform="translate(52.000000, 51.000000)">
                <rect id="矩形" fill="#D8D8D8" opacity="0" x="0" y="0" width="30" height="30" rx="2"></rect>
                <g id="编组-11" transform="translate(1.000000, 3.000000)">
                    <rect id="矩形" stroke="url(#linearGradient-1)" stroke-width="0.5" fill="currentColor" x="0.25" y="0.25" width="27.5" height="19.5" rx="3"></rect>
                    <rect id="矩形" fill="#FFFFFF" transform="translate(8.421217, 9.315041) rotate(36.000000) translate(-8.421217, -9.315041) " x="7.42121747" y="4.81504115" width="2" height="9" rx="1"></rect>
                    <rect id="矩形" fill="#FFFFFF" transform="translate(19.293893, 8.095492) rotate(36.000000) translate(-19.293893, -8.095492) " x="18.2938926" y="3.0954915" width="2" height="10" rx="1"></rect>
                    <rect id="矩形" fill="#FFFFFF" transform="translate(13.669689, 8.902136) rotate(128.000000) translate(-13.669689, -8.902136) " x="12.6696886" y="3.90213598" width="2" height="10" rx="1"></rect>
                    <path d="M16.0680916,14.9807473 L21.433887,21.7585941 C22.1194965,22.6246272 21.9732343,23.8824821 21.1072012,24.5680916 C20.7538759,24.8478076 20.3164391,25 19.8657954,25 L9.13420464,25 C8.02963514,25 7.13420464,24.1045695 7.13420464,23 C7.13420464,22.5493562 7.28639708,22.1119195 7.566113,21.7585941 L12.9319084,14.9807473 C13.6175179,14.1147142 14.8753728,13.968452 15.7414059,14.6540616 C15.8625552,14.7499715 15.9721817,14.859598 16.0680916,14.9807473 Z" id="三角形" fill="currentColor" opacity="0.486025856"></path>
                </g>
            </g>
        </g>
    </g>
</svg>
/* CSS代码注释开始 */ /* 容器样式 */ #container { display: flex; flex-direction: row; } /* 菜单样式 */ #menu { background-color: #333; color: #fff; width: 200px; height: 500px; } #menu ul { list-style-type: none; margin: 0; padding: 0; } #menu li a { display: block; color: #fff; padding: 10px 20px; text-decoration: none; } #menu li a:hover { background-color: #555; } /* 主体内容样式 */ #main { height: 500px; /* 设定主体内容高度 */ overflow-y: scroll; /* 添加滚动条 */ max-width: 1000px; padding: 20px; background-color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.1); } /* 表单样式 */ .form-row { margin-bottom: 10px; } label { display: inline-block; width: 120px; text-align: right; margin-right: 16px; } input[type="text"], select, button[type="submit"] { width: 300px; height: 36px; border-radius: 2px; border: 1px solid #ccc; padding: 6px 12px; font-size: 14px; box-sizing: border-box; background-color: #f8f8f8; } /* 提交按钮样式 */ button[type="submit"] { background-color: #1E9FFF; color: #fff; } /* 下拉列表样式 */ main select { appearance: none; -webkit-appearance: none; -moz-appearance: none; background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 10 6" xmlns="http://www.w3.org/2000/svg"><path d="M 5,0 10,6 H 0 Z"/></svg>'); background-repeat: no-repeat; background-position-x: calc(100% - 12px); background-position-y: center; } /* 按钮悬浮样式 */ button[type="submit"]:hover { background-color: #0C7DBE; } /* 按钮按下样式 */ button[type="submit"]:active { background-color: #0B6994; } /* 图片样式 */ img { width: 200px; height: auto; margin-left: 10px; border: none; } /* CSS代码注释结束 */
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值