使所有 CSS 内联 - 类问题
我发现这个很棒的类可以转换CSS样式块内联。不过,我认为它有一个问题。例如,如果您有以下内容:
<style type="text/css">
.myclass{
padding:0px;
}
<style>
<p class="myclass" style="padding-top: 40px;">Test</p>
它将把上面的内容转换为:
<p class="myclass" style="padding-top: 40px; padding:0px;">Test</p>
但上面的内容是不正确的。它应该放在前面,因为 padding-top
内联具有优先级,因为它已经是内联的。所以应该是:
<p class="myclass" style="padding:0px; padding-top: 40px;">Test</p>
但我正在努力在课堂上的哪里进行此编辑。我认为这很简单,我可以将其提交给课程创建者,但我很挣扎。
有什么想法吗?
I found this awesome class that converts CSS style blocks to inline. However, I think it has a problem. For example, if you have the following:
<style type="text/css">
.myclass{
padding:0px;
}
<style>
<p class="myclass" style="padding-top: 40px;">Test</p>
It will convert the above to:
<p class="myclass" style="padding-top: 40px; padding:0px;">Test</p>
But the above is incorrect. It should prepend since the padding-top
inline has priority as it is already inline. So it should be:
<p class="myclass" style="padding:0px; padding-top: 40px;">Test</p>
But I am struggling where to make this edit in the class. I thought it would be straightforward and I could submit it to the class creator but I am struggling.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最好的解决方案是创建问题并与开发人员联系。这样他也可以为其他人解决问题。这就是社区的成长。
在构建块之前,快速浏览一下代码,我认为 反转数组 $properties
$properties = array_reverse ( $properties, true )
保留键链接的第 318 行构建块的顶部将反转所有内容。希望有帮助!
不确定这是否会带来任何其他问题,请尝试一下。
The best solution is create an issue and get in touch with the developer. So he can fix it for others too. That's a growth of the community .
Just going through the code in a quick way what I think is before building the chunks reverse the array $properties
The
$properties = array_reverse ( $properties, true )
which preserves the key on the top of build chunks on line 318 as linked will reverse all.Hope that helps!
Not sure whether this will bring any other issues, just try.
我认为
并没有错。因为内联样式会覆盖类样式
in my opinion
isn't wrong. because a inline-style overwrite a class-style
应该在最新版本中修复:请参阅 https://github.com/tijsverkoyen/CssToInlineStyles
Should be fixed in the latest version: see https://github.com/tijsverkoyen/CssToInlineStyles