powershell:替换在文本文件中使用其等效的em-entries中找到的像素值,从csv文件中获取数据
因此,我在这里还有另一个问题,有点跟进我的第一个问题。方案:我有一个文本文件(实际上是一个SCSS文件),该文件有很多不同的像素条目,例如Fe Margin-Width:14px;填充:10px 20px; ..等。我还制作了一个包含大量条目的CSV文件,第一列:值像素,第二列:ems中的值。不,我想将文件中的每个像素值与等效的EM值交换。有人可以帮我吗?
好的,谢谢您的快速回复,还有一些信息: 这是我的scss-file(文本文件)的一部分
#anmelden+#NewsletterAbmeldung {
background-color: #efefef;
padding: 23px 23px 20px;
border-radius: 7px;
border: 1px solid #d9d9d9;
}
,在这里,CSV文件中的几行
..
7px;0,44em
..
20px;1,25em
21px;1,31em
22px;1,38em
23px;1,44em
具有像素尺寸及其在EMS中的等效。因此,我希望脚本要做的是,每当找到第一个(PX)条目时,我都应该由第二个(EM) - 输入代替。最后,我的代码看起来像这样:
#anmelden+#NewsletterAbmeldung {
background-color: #efefef;
padding: 1,44em 1,44em 1,25em;
border-radius: 0,44em;
border: 0,06em solid #d9d9d9;
}
So, I have got another question here, kind of following up my first one. Scenario: I have a text file (it’s actually a scss file) that has got a lot of different entries for pixels, Like f.e. margin-width: 14px; padding: 10px 20px; .. etc. I also made a csv-file containing a lot of entries, first column: value in pixels, second column: value in ems. No I want to exchange every pixel-value found in my file with the equivalent em-value. Can anybody help me with that?
Ok, thanks for the fast reply here is some more info:
This is a part of my scss-file (the textfile)
#anmelden+#NewsletterAbmeldung {
background-color: #efefef;
padding: 23px 23px 20px;
border-radius: 7px;
border: 1px solid #d9d9d9;
}
And here a few lines from csv-file
..
7px;0,44em
..
20px;1,25em
21px;1,31em
22px;1,38em
23px;1,44em
It holds pixel-sizes and their equivalents in ems. So what I would like the script to do is that whenever the first (px) entry is found, I should be replaced by the second (em)-entry. My code in the end would look like this:
#anmelden+#NewsletterAbmeldung {
background-color: #efefef;
padding: 1,44em 1,44em 1,25em;
border-radius: 0,44em;
border: 0,06em solid #d9d9d9;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用转换CSV文件,您可以做到这一点:
但是,查看转换值,很明显,您使用了标准计算,其中默认字体大小为16px,因此1PX等于0.0625EM。
知道这一点,您根本不需要CSV,可以直接进行数学操作:
使用第二个代码也消除了创建具有所有可能像素值及其等效的EM值的文件的必要性(有可能省略有些..)
如果您是当前的文化格式,则使用十进制 comma (与我的荷兰人机器相同),则可以用小数点替换线
以
获取这些值 point 在CSS中应使用
Using your conversion csv file, you could do this:
However, looking at the converted values, it is clear you used the standard calculation, where the default font size is 16px and therefore 1px equals 0.0625em.
Knowing this, you don't need the csv at all and can do the math straight away like this:
Using the second code also eliminates the need for creating a file with all possible pixel values and their equivalent em values (with the possibility of omitting some..)
If you're current culture formats numbers with a decimal comma, (same as my Dutch machine), you can replace line
with
to get these values with a decimal point as should be used in CSS