我想將數千個硬編碼的 CSS 像素值更改為一個可重復使用該值的變數,這樣如果該值是,height: 100px;那么新值將是height: calc(100px / var(--resoRatio);. 而且我需要考慮多次包含“px”的行。
For each line
for each 'px'
move to the left until either a ':', ',' or ' ' (space) is identified
select the remaining value along with 'px' starting from first detected colon, comma or space
store selection in variable X
replace content after ':' with 'calc(X / var(--resoRatio))'
這可以通過 Visual Studio Code 查找并替換為正則運算式來完成嗎?
uj5u.com熱心網友回復:
做一個正則運算式搜索
height:\s*(\d px)
如果您有小尺寸(100.3px),請使用
height:\s*([\d.] px)
用。。。來代替
height: calc($1 / var(--resoRatio))
編輯
如果您想要通用屬性,您可以多次應用
搜索
(\w )\s*:\s*(\d px)
用。。。來代替
$1: calc($2 / var(--resoRatio))
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/406632.html
標籤:
下一篇:如何在collection_select中修復此sort_by在瀏覽器中有效,但在Capybara中回傳“字串與nil的比較失敗”錯誤
