Creating a jquery mobile text field on the same line as text

Is there a way to do the following with jQuery Mobile?

Hello [________________________]

instead of what jQuery Mobile is currently doing, which puts these two on multiple lines:

Hello

[________________________]

I am currently creating my text and text like this:

<div id="customTagEntryDiv">
  <span id="userTag">Hello</span>
  <input type="text" name="customTagField" id="customTagField" value=""  />
  </div> 
+5
source share
3 answers

Yes, you can use field containers with data-role="fieldcontain".

For instance:

<div data-role="fieldcontain">
    <label for="name">Text Input:</label>
    <input type="text" name="name" id="name" value=""  />
</div>  

With the above code, you should get something like this:

Text input: [ ____________ ]

not something like this:

Entering text:
[ ____________ ]

"" : , , .. , , , ...


, - :

<div id="customTagEntryDiv" data-role="fieldcontain">
    <label id="userTag" for="customTagField">Hello</label>
    <input type="text" name="customTagField" id="customTagField" value=""  />
</div> 

- : http://jquerymobile.com/demos/1.1.1/docs/forms/textinputs/

, .

+16

float: left . . -:

http://jsfiddle.net/den232/WzH3Y/

    .floatleft {
    float:left;
 }
.floatright {
    float:right;
 }
.forceinline{  /* Prevent fieldcontain from doing a BLOCK thing */
    display:inline !important;
}
.textwidth {  /* limit width of input fields */
    width:80px;
}
.closespacing { /* controls spacing between elements */
    margin:0px 5px 0px 0px;
 }
.bigselect {   /* centers select with big buttons */
    padding: 0px;
    margin:2px 5px 0px 0px;
 }
.biginputheight {   /* matches text input height to big buttons */
    padding-top:10px !important;
    padding-bottom:12px !important;
}
.miniinputheight { /* matches text input height to minibuttons */
    padding-top:5px !important;
    padding-bottom:5px !important;
}
<div data-role="page" class="type-home">

<ul data-role="listview">
  <li  data-role="fieldcontain">first LI line</li>
  <li  data-role="fieldcontain">

    <div class='floatleft closespacing'>
        Big Buttons<br>More Text
    </div>


    <div  class='floatleft textwidth'>
      <input type="text" placeholder="left" class='biginputheight'></input>
    </div>  

    <div  class='floatright textwidth'>
      <input type="text" placeholder="right" class='biginputheight'></input>
    </div>  

  </li>
  <li  data-role="fieldcontain">

    <div class='floatleft closespacing'>    
        Small Buttons
    </div>


    <div  class='floatleft textwidth'>
      <input type="text" placeholder="e2" class='miniinputheight'></input>
    </div>  


    <div class='floatright closespacing'>
      <div  class='floatright closespacing'>    
        e3 Text<br>on right
      </div>
      <div  class='floatright textwidth'>
        <input type="text" placeholder="e3" class='miniinputheight'></input>
      </div>  
    </div>
  </li>
  <li  data-role="fieldcontain">last LI line</li>

</ul><!-- /listview -->  

0

This doesn't work anymore:

<div data-role="fieldcontain"></div>

An old-fashioned table works fine:

<table>
    <tr>
        <td>Label #1:</td>
        <td><input type="text"></td>
    </tr>
</table>
0
source

All Articles