CSS - 使用SVG掩码在Firefox中无法正确显示(CSS - Using SVG mask not displaying correctly in Firefox)
我有以下HTML-
<span class="svg-star svg-finance"></span>
这是CSS: -
.svg-star { height: 50px; width: 50px; margin: 2px 5px; -webkit-mask: url(../img/icon-favourite.svg) no-repeat 50% 50%; mask: url(../img/icon-favourite.svg) no-repeat 50% 50%; display: inline-block; } .svg-finance { background-color: #CFCABD; }
但在Firefox中,它显示为图像的左侧,如在Safari,Chrome等中,它显示在右侧: -
知道我错过了什么吗?
Firefox中忽略了mask和webkit-mask。
I have the following HTML-
<span class="svg-star svg-finance"></span>
and here is the CSS:-
.svg-star { height: 50px; width: 50px; margin: 2px 5px; -webkit-mask: url(../img/icon-favourite.svg) no-repeat 50% 50%; mask: url(../img/icon-favourite.svg) no-repeat 50% 50%; display: inline-block; } .svg-finance { background-color: #CFCABD; }
But in Firefox it appears as the left side of the image where as in Safari, Chrome etc it appears correctly as per the right side:-
Any idea what I am missing?
The mask and webkit-mask are both ignored in Firefox.
原文:https://stackoverflow.com/questions/35298016
最满意答案
尝试发布未处理的警告。
不过,我也记得我在
<map>
得到了一些来自<xtree>
4级警告,可以安全地忽略它(IIRC是C4702 ,这是无害的)。为了避免这种警告,我在STL
#include
一些合适的#pragma warning
指令(包含在正确的#ifdef
以便让他们仅考虑MSVC ++,感谢@Alexandre C.提醒我):#ifdef _MSC_VER //Disable the C4702 warning for the following headers #pragma warning(push) #pragma warning(disable:4702) #endif // _MSC_VER //map STL container #include <map> //list STL container #include <list> //vector STL container #include <vector> #ifdef _MSC_VER #pragma warning(pop) #endif
您也可以简单地将警告等级降低到3(甚至更低),只需在该部分使用:
#ifdef _MSC_VER // Lower the warning level to 3 just for this section #pragma warning(push, 3) #endif //map STL container #include <map> //list STL container #include <list> //vector STL container #include <vector> #ifdef _MSC_VER #pragma warning(pop) #endif // _MSC_VER
有关更多信息,请参阅
#pragma warning
的文档 。Try to post the non-treated warnings.
However, I too remember that I got some level 4 warning from
<xtree>
in<map>
, that could be safely ignored (IIRC it was C4702, which is harmless).To avoid the warning, I put around the STL
#include
s some appropriate#pragma warning
directives (enclosed in the correct#ifdef
s to have them considered only on MSVC++, thanks to @Alexandre C. for reminding me of it):#ifdef _MSC_VER //Disable the C4702 warning for the following headers #pragma warning(push) #pragma warning(disable:4702) #endif // _MSC_VER //map STL container #include <map> //list STL container #include <list> //vector STL container #include <vector> #ifdef _MSC_VER #pragma warning(pop) #endif
You could also simply lower the warning level to 3 (or even lower) just in that section with:
#ifdef _MSC_VER // Lower the warning level to 3 just for this section #pragma warning(push, 3) #endif //map STL container #include <map> //list STL container #include <list> //vector STL container #include <vector> #ifdef _MSC_VER #pragma warning(pop) #endif // _MSC_VER
For more info, see the documentation of
#pragma warning
.
相关问答
更多-
什么时候应该使用STL算法而不是使用自己的?(When should the STL algorithms be used instead of using your own?)[2022-03-06]
简短的回答:永远。 长答案:永远。 这就是他们在那里。 它们针对STL容器进行了优化,它们比你自己写的任何东西都更快,更清晰,更习惯。 你应该考虑推出自己的唯一情况是如果你能阐明STL算法不能满足的非常具体的任务关键需求。 编辑补充说:(好吧,真的不是真的总是,但如果你必须问你是否应该使用STL,答案是“是”)。 Short answer: Always. Long answer: Always. That's what they are there for. They're optimized for u ... -
C ++ STL优化警告:代码问题还是更危险?(C++ STL optimization warning: problem with the code or something more sinister?)[2023-04-19]
我想我终于得到了编译器暗示的东西。 循环不是在一个整数上执行的,所以我认为编译器试图告诉的是它实际上不能计算循环将执行多少次运行。 您使用的警告实际上通常应与-funsafe-loop-optimizations ,从gcc优化选项页面 : -funsafe-loop-optimizations如果给出,循环优化器将假定循环索引不会溢出,并且具有非平凡退出条件的循环不是无限的。 即使循环优化器本身无法证明这些假设是有效的,也可以实现更广泛的循环优化。 使用-Wunsafe-loop-optimization ... -
尝试发布未处理的警告。 不过,我也记得我在
-
你的地图名称是poweruplist而不是powerups (你在for循环中使用这个名字)。 如果这不是错误的原因,那么看起来你是for循环是在一个函数中,它通过const引用接受映射(或者是类的const成员函数)。 在这种情况下,您的迭代器类型应该是const_iterator而不是iterator 。 Your map name is poweruplist not powerups (You are using this name in the for loop). If this is not ...
-
您必须像函数所期望的那样使用默认分配器。 你有两种不同的类型,没有办法解决这个问题。 只需在操作向量之前调用reserve ,即可获得内存分配。 想想可能发生的坏事。 该函数可以使用向量并开始添加更多元素。 很快,你可以溢出你分配的堆栈空间; 哎呀! 如果您真的关心性能,那么更好的方法是用自定义内存管理器替换operator new和kin。 我已经这样做了,分配可以大大改善。 对我来说,分配大小为512或更小的大小约为4次操作(移动几个指针); 我使用了池分配器) You have to use the ...
-
STL中的迭代器比较(Iterators comparisions in STL)[2023-02-21]
这里的问题是比较运算符将iterator与iterator和const_iterator与const_iterator进行比较。 如果运算符是非成员函数,编译器将找到从iterator到const_iterator的转换并调用const_iterator比较函数。 如果比较运算符是成员函数,它将在lhs上调用,在示例中,它是iterator并且无法将const_iterator转换为iterator 。 解决方法的作用是将const_iterator为lhs,并且因为iterator可以转换为const_i ... -
任何包含在你的MFC项目中的STL应该包含在DEBUG_NEW的定义之前。 这在过去是一个问题(现在不再是这样了,因为我不能在VS 2010中重现它)。 // myfile.cpp #ifdef _DEBUG #define new DEBUG_NEW #endif // This will cause the error #include
而 // myfile.cpp // will work OK #include #ifdef _DEBUG #define ... -
将STL与Alchemy一起使用(using STL with Alchemy)[2021-07-19]
问题不在STL中。 使用线程安全函数__gnu_cxx::__exchange_and_add和__gnu_cxx::__atomic_add引用计数std::string的GNU实现。 问题是__exchange_and_add / __atomic_add被破坏了。 解决方案是通过良好实现这些功能来重建STL。 幸运的是,Alchemy发行版为我们留下了一些面包屑。 请参阅$ALCHEMY_HOME/avm2-libc/README ,它告诉我们如何执行此操作: The sources used to ... -
STL列表问题C(STL list problem C)[2022-09-09]
不,因为这些是不同的语言。 仅仅因为在名称中的常见字母之后只有文本字符串“++”并不意味着什么 - 这与尝试在Python中使用Java容器相当。 如果你想使用STL,你必须使用C ++编译器。 No, because these are different languages. Just because one only has the text string "++" after a common letter in the name doesn't mean anything - this is th ... -
在JavaFX中导入STL文件(Import STL file in JavaFX)[2022-05-26]
由于您已经在使用此站点的STL导入器,因此您可以在同一Web中找到一个3D模型浏览器,您可以使用它来预览模型,然后再将其导入JavaFX应用程序。 如果无法使用此浏览器导入它们,则问题可能与文件中的无效STL格式有关。 如果它们已导入,则问题可能出在您的应用程序中。 将调用嵌入try-catch并发布您可能想要的异常。 StlMeshImporter stlImporter = new StlMeshImporter(); try { stlImporter.read(this.getClass ...