我试图在 Jquery 中翻转后应用背景渐变。我在 jsfiddle 上做了一个基本的演示,但问题出在 safari 中,它没有重新应用渐变,并且在用户滚下后我得到了一个平面颜色。
这是我的jQuery代码:
$(".default").mouseover(function() {
$(this).css({ background: "#000" });
});
$(".default").mouseout(function() {
$(this).css({ backgroundColor: "#1664b7",
background: "url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzFkOGRkNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjIwJSIgc3RvcC1jb2xvcj0iIzE5NzNjMSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjkwJSIgc3RvcC1jb2xvcj0iIzE1NWViMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=)",
background: "-moz-linear-gradient(top, #1d8dd4 0%, #1973c1 20%, #155eb2 90%)",
background: "-webkit-gradient(linear, left top, left bottom, color-stop(0%,#1d8dd4), color-stop(20%,#1973c1), color-stop(90%,#155eb2))",
background: "-webkit-linear-gradient(top, #1d8dd4 0%,#1973c1 20%,#155eb2 90%)",
background: "-o-linear-gradient(top, #1d8dd4 0%,#1973c1 20%,#155eb2 90%)",
background: "-ms-linear-gradient(top, #1d8dd4 0%,#1973c1 20%,#155eb2 90%)",
background: "linear-gradient(to bottom, #1d8dd4 0%,#1973c1 20%,#155eb2 90%)",
filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='#1d8dd4', endColorstr='#155eb2',GradientType=0 )"
});
});
我使用http://www.colorzilla.com/gradient-editor/上的颜色渐变生成器来制作渐变。
任何帮助表示赞赏。谢谢!