【问题标题】:change link colour blue into white将链接颜色从蓝色更改为白色
【发布时间】:2014-04-29 05:03:13
【问题描述】:

我有一个网页视图,我想将链接颜色 blue 更改为 white 。在 html 标签下方,我正在更改字体,效果很好。请告诉我更改链接颜色的html标签是什么。

 NSString* htmlContentString = [NSString stringWithFormat:
                                             @"<html>"
                                            "<style type=\"text/css\">"
                                           "body { background-color:transparent; color: #eadfa8;font-family:Arial; font-size:24; }"
                                           "</style>"
                                           "<body>"
                                           "<p>%@</p>"
                                           "</body></html>", content1];

            [webview loadHTMLString:htmlContentString baseURL:nil];

【问题讨论】:

    标签: html objective-c uiwebview


    【解决方案1】:

    在 CSS 中添加 a{color:white}

    NSString* htmlContentString = [NSString stringWithFormat:
                                                 @"<html>"
                                                "<style type=\"text/css\">"
                                               "body { background-color:transparent; color: #eadfa8;font-family:Arial; font-size:24; }"
    "a {color: white;}"
    
                                               "</style>"
                                               "<body>"
                                               "<p>%@</p>"
                                               "</body></html>", content1];
    
                [webview loadHTMLString:htmlContentString baseURL:nil];
    

    【讨论】:

      【解决方案2】:

      如果您想将所有链接颜色更改为白色,您可以将其添加到您的 css :

      a:link{text-color:#ffffff}
      

      【讨论】:

        【解决方案3】:

        使用以下代码:

        NSString* htmlContentString = [NSString stringWithFormat:
                                                     @"<html>"
                                                    "<style type=\"text/css\">"
                                                   "body { background-color:transparent; color: #eadfa8;font-family:Arial; font-size:24; }"
                                                   "body.a:link {color:#FFFFFF !important;}"
                                                   "</style>"
                                                   "<body>"
                                                   "<p>%@</p>"
                                                   "</body></html>", content1];
        

        您可以像下面这样设置链接颜色:

        "body.a:link {color:#FFFFFF !important;}"
        

        【讨论】:

        • 仍然是蓝色的..为什么?
        猜你喜欢
        • 2018-02-16
        • 1970-01-01
        • 2022-10-18
        • 2023-04-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多