开发者

Replace size parameter in css

开发者 https://www.devze.com 2023-01-21 23:32 出处:网络
I want to replace all font-size-parameters in a html document (css attributes). 开发者_StackOverflowI\'m using .net with c#.

I want to replace all font-size-parameters in a html document (css attributes). 开发者_StackOverflowI'm using .net with c#. I guess it could be done with some regular expression.

Am I forgetting some other ways to set the font size?

Example:

<html>
    <head>
        <style type="text/css">
             .t {
                 font-size: large;
             }
        </style>
    </head>
    <body>
        <span style="font-size: medium" />
    </body>
</html>

into:

<html>
    <head>
        <style type="text/css">
             .t {
                 font-size: large_replaced;
             }
        </style>
    </head>
    <body>
        <span style="font-size: medium_replaced" />
    </body>
</html>


if you use relative unit like em, ex etc for all font dimensions in your page. By adjusting only html elements' size you manage all fonts

big fonts

html{
 font-size:18px;
}

smaller fonts

html{
 font-size:18px;
}

you can manage that form javascript, better (also using cookies).


I ended up using the following regex to find where to replace:

/style=\"[.]*font-size:(?<size>[^;]*);[^\"]*[\"]/
/<style[^<]*font-size:(?<size>[^;]*);[^<]*[<]/
0

精彩评论

暂无评论...
验证码 换一张
取 消