How do I align Label and Input on the same line to the right?

אברגיל יעקובו

I'm struggling while trying to locate 2 buttons on the left of an input field. I already tried several suggestions on the internet but I couldn't make it the way I want.

<div class="col-xs-6" >
    <div class="row">
        <div class="col-xs-12">
            <div class="pull-right">
                <div class="search" style="height: 18px" ng-if="vm.showSearch()">
                    <form style="margin:0px" name="filter_actions"  novalidate>
                        <div>
                            <input id="freeTextSearch" type="text"  class="form-control input-sm" autofocus ng-change="vm.filterTable(Search)" ng-model="Search"
                                   style="text-indent: 5px;"  minlength="1" ng-model-options="{debounce:100}" id="Search" name="Search" placeholder="Search fields">
                            <a ng-show="Search" ng-click="localSearch = ''; vm.filterTable(localSearch)"><i style="vertical-align: middle; top:4px; right:35px; position: absolute" class="glyphicon glyphicon-remove"></i></a>
                        </div>
                    </form>
                </div>
                <div class="btn-group btn-group-xs" role="group" aria-label="...">
                    <label class="btn btn-default" role="button" ng-click="vm.popUp()"><i class="fa fa-expand" style="color:darkgreen;"></i></label>
                </div>
            </div>
        </div>
    </div>
</div>  

This is how it looks like :

enter image description here

Vickel

Keep in mind, that label is an inline element similar to span, so you need to set its css to display: inline-block to behave like a div

once you have done this, the easiest way to have them in the same line is to use display:flex and flex-wrap: nowrap on the parent div.

here is my favorite flex-cheat-sheet

I have simplified your example and you can see how this works clicking below on Run code snippet.

.pull-right {
  display: flex;
  flex-wrap: nowrap;
}

.pull-right input{  border: 1px solid green;}
.pull-right label{ border: 1px solid red; display: inline-block;}
<div class="pull-right">
  <div class="search" style="height: 18px" ng-if="vm.showSearch()">
    <form style="margin:0px" name="filter_actions" novalidate>
      <div>
        <input id="freeTextSearch" type="text" 
        class="form-control input-sm" autofocus ng-change="vm.filterTable(Search)" 
        ng-model="Search" 
        style="text-indent: 5px;" minlength="1" 
        ng-model-options="{debounce:100}" id="Search" name="Search" placeholder="Search fields">
        <a ng-show="Search" 
        ng-click="localSearch = ''; vm.filterTable(localSearch)">
        <i style="vertical-align: middle; top:4px; right:35px; position: absolute" 
        class="glyphicon glyphicon-remove">      </i></a>
      </div>
    </form>
  </div>
  <div class="btn-group btn-group-xs" role="group" aria-label="...">
    <label class="btn btn-default" role="button" ng-click="vm.popUp()"><i class="fa fa-expand" style="color:darkgreen;">your icons</i></label>
  </div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How may I align text to the left and text to the right in the same line?

How do I right align div elements?

How to align two paragraphs to the left and right on the same line?

How do i put the label and slider on the same line

How can I align the text that didn't fit the first line to right in CSS, like they do in poetry?

How do I align two elements on the same line?

How do I align an input with the top of multi-line text?

how to align heading in center and icon in right on the same line and is responsive

How do I right align a button next to a label in a form?

How do I align text and buttons on the same line?

How do i center the panel-body, with input-label align with left side of input box?

How do I force an input to stay on the same line as its label with Bootstrap form-control class?

How to align input with a checkbox (pull-right) in the same row?

Align right input and left label

How do i align all these Read Mores in the same line in bootstrap

How do I align the label and input in a one line?

how do i align my th text in a same line

How do I align the dropdown arrow on a HTML5 date input to the right side?

How to align <label> on the same line with other element

flutter ListView - How do I align left and right at the same time?

How do I make input field and an image come in same line?

How to align button left and right in the same line?

How can I put the label and the input on the same line please?

How to align the label and the input at the same line in Bootstrap 5?

How do I align text in the same line?

Python 3: How do I add input and a string to the same line?

How do I force label and dropdown to be on same line?

How to align upload and input field in the same line?

How do I align a text on the same line as a button?