开发者

Replace size parameter in css

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜