Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap .form-horizontal not working

I am a first-try bootstrap guy. The thing i want to achieve is to have labels and inputs same line nice and clean.

Anyone can explain me why in the below example labels are still above inputs? Am i doing something wrong?

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta application-name="Test-System">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap Latest compiled and minified CSS -->
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

    <!-- Bootstrap Latest compiled and minified JavaScript -->
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

    <!-- jQuery UI from Google CDN -->
    <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
    <title></title>
</head>
<body>

    <form class="form-horizontal">
        <div class="control-group">
            <label for="input1" class="control-label">Label</label>
            <div class="controls">
                <input id="input1" type="text">
            </div>
        </div>

        <div class="control-group">
            <label for="input2" class="control-label">Label</label>
            <div class="controls">
                <input id="input2" type="text">
            </div>
        </div>
    </form>

     <!-- jQuery from Google CDN -->
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
     <!-- jQuery UI from Google CDN -->
     <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
</body>
</html>
like image 508
Stefanos Vakirtzis Avatar asked Feb 18 '14 19:02

Stefanos Vakirtzis


1 Answers

<div class="controls">
                <label for="input1" class="control-label">Label</label>
                <input id="input1" type="text">
 </div>

Is this what you are looking for?

EDIT Horizontal label from outside of input's div.

    <div class="control-group">
        <label for="input1" class="control-label col-sm-2">Label</label>
        <div class="controls col-sm-10">
            <input id="input1" type="text">
        </div>
    </div>
like image 96
Chris Avatar answered Oct 09 '22 22:10

Chris