【问题标题】:inner html change font size on all html tags内部 html 更改所有 html 标签的字体大小
【发布时间】:2017-12-12 05:16:01
【问题描述】:

<div>
<p style="margin: 0in 0in 0.0001pt; text-align: center; font-size: 18pt; font-family: 'Times New Roman', serif; font-weight: bold;"><span style="font-size: 10.0pt; font-family: Verdana, sans-serif;">Hello test</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 8.0pt; font-family: Verdana, sans-serif;">&nbsp;</span></p>
<p style="text-align: justify; margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span style="font-size: 6.5pt; font-family: Verdana, sans-serif;">Testing font<strong></p>
</div>

我有一个像上面这样的innerhtml,有没有一种方法可以在不使用正则表达式的情况下更改所有字体大小

【问题讨论】:

    标签: angular innerhtml


    【解决方案1】:

    您可以使用字符串替换方法。

    例如

          let html = `<div><p style="margin: 0in 0in 0.0001pt;      
                        text-align: center; font-size: 18pt; font-family: 
                       'Times New Roman ...... </div>` 
          let newHtml = html.replace('font-size: 18pt', 'font-size: 
                        '20pt'); 
    

    然后在视图页面中渲染 newHtml。

         <div [innerHtml]="newHtml"> </div> 
    

    【讨论】:

      猜你喜欢
      • 2020-05-19
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-24
      相关资源
      最近更新 更多