简体   繁体   English

悬停时更改背景SVG的笔触

[英]Change stroke of background svg on hover

There is button with text and arrow image: 有带有文本和箭头图像的按钮:

 button { background: #ffffff; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; color: #00aef4; border: 2px solid #00aef4; display: inline-block; font-weight: normal; line-height: 2.3; margin: 0; outline: 0; padding: 0 1em; text-align: center; vertical-align: middle; } .button:after { background: url("/svg/right-arrow.svg") no-repeat; content: ""; display: inline-block; height: 12px; margin-left: 10px; width: 8px; } .button:hover { background: #00aef4; color: #ffffff; } 
 <button class="button">Next</button> 

So, I need to change stroke color of arrow on hover without javascript. 因此,我需要在没有javascript的情况下更改悬停箭头的笔触颜色。 How to make it possible? 如何使其成为可能?

UPD Stackoverflow doesn't allow to add content svg-file. UPD Stackoverflow不允许添加内容svg文件。 I publush it to gist: https://gist.github.com/bibimij/a5ae9dcc309db5547a31 我将其发布到要点: https ://gist.github.com/bibimij/a5ae9dcc309db5547a31

without seeing your svg file you could just create a new image file with the colour you need? 如果没有看到您的svg文件,您可以仅创建具有所需颜色的新图像文件?

background: url("/svg/right-arrow-hovercolor.svg") no-repeat; 背景:url(“ / svg / right-arrow-hovercolor.svg”)不重复;

I used svg to create an arrow try this 我用svg创建了一个箭头试试这个

 button { background: #ffffff; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; color: #00aef4; border: 2px solid #00aef4; display: inline-block; font-weight: normal; line-height: 2.3; margin: 0; outline: 0; padding: 0 1em; text-align: center; vertical-align: middle; padding-right:30px; } .button svg{ transform:scale(.5,.5); position:absolute; margin-top:-45px; margin-left:5px; } .button:hover { background: #00aef4; color: #ffffff; } .button:hover svg path{ fill:#00aef4; stroke:white; 
 <button class="button">Next <svg width="50" height="60"> <path d=" m 0 20 30 0 0 -20 20 30 -20 30 0 -20 -30 0 "fill="white" stroke="#00aef4" stroke-width="2"/> </svg> </button> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM