2016-06-22 3 views
2

Ich habe zwei divs in meiner Benutzeroberfläche. Ein div enthält ein Label. Und der andere enthält einen Dateiwähler. Ich möchte, dass sie Seite an Seite stehen.UI Div Alignments in CSS Bootstrap und HTML

Aber jetzt sind sie vertikal gestapelt. enter image description here

Wie kann ich sie horizontal mit ein wenig Abstand zwischen ihnen ausrichten?

<div> 
     <div> 
      <label>Upload File</label> 
     </div> 
     <div class="ui-select"> 
      <input type="file" name="files" ng-files="getTheFiles($files)" /> 
     </div> 
    </div> 
    <div style="clear:both;"></div> 
    <br/> 
    <div style="height:3px; background-color:#cccccc; width:100%; margin-top:5px;"></div> 
    <div style="padding-top:10px;"> 
     <input type="submit" class="btn btn-default" style="width:100px;" value="Upload" /> 

    </div> 
+0

Bitte senden Sie uns eine Jsfiddle zusammen mit CSS – geeksal

+0

Ihre zwei Haupt Container müssen 'Display sein: Inline-block', auch muss die Breite –

+0

festgelegt werden, wenn sie Bootstrap-Form Verwendung Klasse Form inline ist' '

"' – Mani

Antwort

2

Ich denke, das Ihr Problem

.form-label,.form-input{ 
 
    display:inline-block; 
 
    margin-right:5px; 
 
}
<div> 
 
     <div class="form-label"> 
 
      <label>Upload File</label> 
 
     </div> 
 
     <div class="ui-select form-input"> 
 
      <input type="file" name="files" ng-files="getTheFiles($files)" /> 
 
     </div> 
 
    </div>

0

Wenn Sie sie in einem form Element der Klasse lösen sollten Sie Bootstrap verwenden können form-inline

Wenn Sie wickeln sind Ohne Bootstrap können Sie float: left und einige Marge verwenden, um das zu erstellen Raum zwischen ihnen wie folgt aus:

.inline{ 
 
    float: left; 
 
} 
 

 
.ui-select{ 
 
    margin-left: 12px; 
 
}
<div class="inline"> 
 
    <label>Upload File</label> 
 
</div> 
 
<div class="inline ui-select"> 
 
    <input type="file" name="files" ng-files="getTheFiles($files)" /> 
 
</div>

1

Sie können dies tun, nur durch Zugabe von display: inline-block und .. wie Bootstrap
Oder, wenn Sie bereits Bootstrap mit links Schwimmer verwenden nur ihr Netz Klassen wie "col-xs-6" für beide divs
getbootstrap.com/css/#grid

.label-container{display:inline-block;float:left;margin-right:25px;} 
 
.input-container{display:inline-block;float:left;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<div> 
 
     <div class="label-container"> 
 
      <label>Upload File</label> 
 
     </div> 
 
     <div class="input-container"> 
 
      <input type="file" name="files" ng-files="getTheFiles($files)" /> 
 
     </div> 
 
    </div> 
 
    <div style="clear:both;"></div> 
 
    <br/> 
 
    <div style="height:3px; background-color:#cccccc; width:100%; margin-top:5px;"></div> 
 
    <div style="padding-top:10px;"> 
 
     <input type="submit" class="btn btn-default" style="width:100px;" value="Upload" /> 
 

 
    </div>

0

Ersetzen Sie Ihren Code diesen.

<div> 
    <div style="float:left;"> 
     <label>Upload File</label> 
    </div> 
    <div class="ui-select" style="float:left; margin-left:20px;"> 
     <input type="file" name="files" ng-files="getTheFiles($files)" /> 
    </div> 
</div> 
<div style="clear:both;"></div> 
<br/> 
<div style="height:3px; background-color:#cccccc; width:100%; margin-top:5px;"></div> 
<div style="padding-top:10px;"> 
    <input type="submit" class="btn btn-default" style="width:100px;" value="Upload" /> 

</div>