当前位置: 动力学知识库 > 问答 > 编程问答 >

r - How to put a box and its label in the same row? (shiny package)

问题描述:

In Shiny, say i am using textInput, the field/box is always shown underneath the label. Is there a way that I can force them to be in the same row?

ie, Label: BOX

instead of

Label:

Box

网友答案:

Take at the look at the HTML output from fileInput, e.g.

fileInput("myfile", "Normal Label") 

The HTML it generates is:

<label>Normal Label</label>
<input id="myfile" type="file"/>
<div id="myfile_progress" class="progress progress-striped active shiny-file-input-progress">
  <div class="bar"></div>
  <label></label>
</div>

The label element has a line break by default. You need to change the CSS to get rid of that, i.e. you need to add something like

shinyUI(bootstrapPage(
  tags$head(    
    tags$style("label {display:inline;}")
  ),
  fileInput("myfile", "Inline Label")
))

This will of course effect all label elements, not just this one. If you only want to modify this one you need to include the HTML code directly in your app. You can do this by using the HTML function (note the additional CSS statement).

shinyUI(bootstrapPage(
  HTML('
  <label style="display: inline;">Inline Label</label>
    <input id="myfile" type="file"/>
    <div id="myfile_progress" class="progress progress-striped active shiny-file-input-progress">
    <div class="bar"></div>
    <label></label>
    </div>
')
))
分享给朋友:
您可能感兴趣的文章:
随机阅读: