zoukankan      html  css  js  c++  java
  • 快应用richtext组件背景色填充问题

    现象描述:

    车机上是深色背景模式,使用richtext包裹网页内容时,出现白色背景边框,影响整体深色背景,问题截图如下:

    问题代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    <richtext type="html" class="rich-text">{{content}}</richtext>
    <script>
        export default {
            private: {
                content:           
                     <body style="#006000;">
                        <div class="item-content"  style="#006000;">
                            <style>h1{color: yellow;}</style>
                            <p class="item-title">h1</p>
                            <h1>文本测试</h1>
                            <p class="item-title">h2</p>
                            <h2>文本测试</h2>                 
                        </div>
                    </body>          
                },
            }
    </script>
    <style>
    .rich-text {
            #cd853f;
        }
    </style>

    问题分析:

    车机上在使用richtext组件包裹html内容后,在快应用里通过class设置background-color是不生效的。如果richtext包裹的内容只含网页的body部分,即使在body上设置了背景色,在展示富文本时周围也会出现一圈白色边框。需要在richtext里写完整的html,且在其html标签上设置背景色,背景色在展示时才能覆盖边框,不会出现白色的空隙。

    解决方法:

    在richtext里包裹一个完整的html格式的网页,html标签中设置背景色。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    <richtext type="html" class="rich-text">{{content}}</richtext>
    <script>
        export default {
            private: {
      
                content:
                    `<!DOCTYPE html>
                    <html lang="en" style="#006000;">
                        <head>
                        <meta charset="UTF-8" />
                        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
                        <title>Document</title>
                        </head>
                        <body>
                            <div class="item-content">
                                <style>h1{color: yellow;}</style>
                                <p class="item-title">h1</p>
                                <h1>文本测试</h1>
                                <p class="item-title">h2</p>
                                <h2>文本测试</h2>                 
                            </div>
                        </body>
                    </html>`
            },
        }
    </script>
    <style>
    .rich-text {
            #cd853f;
    }
    </style>

    修改后效果图如下:

    原链接:https://developer.huawei.com/consumer/cn/forum/topic/0204429221972080033?fid=18

    原作者:Mayism

  • 相关阅读:
    记一次proc_open没有开启心得感悟
    Nginx 502 Bad Gateway 的错误的解决方案
    Linux安装redis,启动配置不生效(指定启动加载配置文件)
    设置redis访问密码
    LNMP 多版本PHP同时运行
    ***总结:在linux下连接redis并进行命令行操作(设置redis密码)
    设计模式(一)单例模式:3-静态内部类模式(Holder)
    设计模式(一)单例模式:2-懒汉模式(Lazy)
    设计模式(一)单例模式:1-饿汉模式(Eager)
    设计模式(一)单例模式:概述
  • 原文地址:https://www.cnblogs.com/developer-huawei/p/14831626.html
Copyright © 2011-2022 走看看