【问题标题】:Shiny - How to Style a Selected Radio Buttons Label?Shiny - 如何为选定的单选按钮标签设置样式?
【发布时间】:2015-05-05 18:30:17
【问题描述】:

我发现了一个类似的question,但在处理本机形式的 Shiny 单选按钮时没有解决问题;即,没有 HTML。

我有这行:

column(6, h1(radioButtons(inputId="gender", "Gender", choices = list("combined" = "combined", "male only" = "male", "female only" = "female"), inline=TRUE)))

看起来像这样:

我想将标签(例如,“组合”、“仅限男性”、“仅限女性”)加粗。

我尝试设置一个类,class="radioSelect,如下:

column(6, h1(radioButtons(inputId="gender", "Gender", choices = list(class="radioSelect", combined" = "combined", "male only" = "male", "female only" = "female"), inline=TRUE)))

...但最终,有趣且不足为奇的是:

有人对我如何以这种方式将类应用于 Shiny 单选按钮上的标签有任何建议吗?感谢您的关注。

【问题讨论】:

    标签: css r shiny


    【解决方案1】:

    我最终更改了 R 代码以放入一个名为 radioSelect 的类:

    column(6, h1(class="radioSelect", radioButtons(inputId="gender", "Gender", choices = list(...
    

    然后在 CSS 文件中,我使用以下命令访问标签:

    .radioSelect label.radio { ...
    

    这很有效,因为标签上都有“收音机”类。因此我现在可以控制标签了。

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题,发现这可以改变整个 radioButton 输入的样式:

      column(6, h1(radioButtons(inputId="gender", "Gender", choices = list(...)), style = "font-weight:bold;")
      

      【讨论】:

        【解决方案3】:
        <div class="thisForm">
        column(6, h1(radioButtons(inputId="gender", "Gender", choices = list(class="radioSelect", combined" = "combined", "male only" = "male", "female only" = "female"), inline=TRUE)))
        </div>
        
        CSS
        .thisForm{
        font-weight: bold;
        }
        

        至少,他们的文档中似乎是这样做的:http://shiny.rstudio.com/reference/shiny/latest/radioButtons.html

        【讨论】:

          猜你喜欢
          • 2011-06-06
          • 1970-01-01
          • 2010-09-07
          • 1970-01-01
          • 2013-01-13
          • 1970-01-01
          • 2019-01-25
          • 1970-01-01
          • 2013-06-08
          相关资源
          最近更新 更多