防止输入字段中断/包装

时间:2015-07-30 15:07:00

标签: html css forms twitter-bootstrap css3

下面有2个输入字段。一个选择另一个输入文本。即使在移动模式下我也需要它保持内联。

如何防止输入字段破坏?无论屏幕大小如何,它们都保持内联。

String user = "john";
String password = "mypassword";
String host = "127.0.0.1";
String host2 = "192.168.100.23";
int port=22;

try{
    JSch jsch = new JSch();
    Session session1 = jsch.getSession(user, host, port);
    session1.setPassword(password);
    session1.setConfig("StrictHostKeyChecking", "no");
    System.out.println("Establishing Connection...");
    session1.connect();
    System.out.println("Connection established.");

    //Here we do port forwarding to the second host
    int assinged_port = session1.setPortForwardingL(0, host2, 22);
    System.out.println("portforwarding: "+
            "localhost:"+assinged_port+" -> "+host+":"+22);

    //And here we connect to the first host to the forwarded port, not 22
    Session session2 = jsch.getSession(user, host, assinged_port);

    //This is your public key file 
    jsch.addIdentity("~/.ssh/id_rsa");
    session2.setConfig("StrictHostKeyChecking", "no");
    session2.connect();
    System.out.println("The session has been established to "+
            user+"@"+host);

    System.out.println("Crating SFTP Channel.");
    ChannelSftp sftpChannel = (ChannelSftp) session2.openChannel("sftp");
    sftpChannel.connect();
    System.out.println("SFTP Channel created.");


    InputStream out= null;
    out= sftpChannel.get(remoteFile);
    BufferedReader br = new BufferedReader(new InputStreamReader(out));
    String line;
    while ((line = br.readLine()) != null)
        System.out.println(line);
    br.close();
}
catch(Exception e){System.err.print(e);}

3 个答案:

答案 0 :(得分:0)

来自http://getbootstrap.com/css/

Bootstrap的内联表单,如:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<form class="form-inline">
  <div class="form-group">
    <select class="form-control" >
        <option>Thing One</option>
        <option>Thing Two</option>
    </select>
    
  </div>
  <div class="form-group">
    <input type="text" class="form-control">
  </div>  
</form>

文档中的状态“这仅适用于视口中至少为768像素宽的表单。'

您可以直接强制它们在CSS中与流体宽度保持内联并浮动元素。

Ex:https://jsfiddle.net/cm94dup9/

答案 1 :(得分:0)

您可以将表用于选择字段和文本字段。 在表格中,您可以指定宽度,因此两者都是内联的。

<table> 
    <tr><td><div class="form-group">
        <select class="form-control">
            <option value="A">Option A</option><option value="B">Option B</option><option value="C">Option C</option><option value="D">Option D</option>
        </select>
    </div></td></tr>
    <tr><td>
    <div class="form-group">
        <input class="form-control" type="text">
    </div>
    </td></tr>
    </table>

如果你的意思是内联,两者都有相同的宽度并且彼此相对。并非两者都在同一条线上。

答案 2 :(得分:0)

对我有用的是将标签和输入、选择、复选框等包装在一个 div 标签中。


<form>
<div style=" white-space: nowrap;overflow: hidden;" >
<label>
<select>
<option value="?">Select</option>
<option value="february">February</option>
<option value="march">March</option>
<option value="april">April</option>
</select>
</label>
</div>
</form