xabi_sides
xabi_sides

Reputation: 334

Align element with input (and not with label) - Bootstrap 3

In my test case, I'm up to aligning in columns an input with its label and a hyperlink. The problem is that hyperlink gets aligned to label, and not to input:

enter image description here

The code is as follows:

       <div class="row">

            <div class="form-group col-xs-4">
                <label class="form__label" for="form__field__recipientId">Código
                    beneficiario </label> <input class="form-control input-md col-xs-8"
                    id="form__field__recipientId" name="form__field__recipientId"
                    type="text" placeholder="Introduce ordenante">
            </div>

            <div class="form-group col-xs-4">
                <a class="form__side__hyperlink" href="">Buscar beneficiario</a>
            </div>

        </div>

I have tried many things, mainly form-inlining the elements, but I don't think I'm doing it correctly since I end up messing things up.

Upvotes: 0

Views: 65

Answers (2)

Aslam
Aslam

Reputation: 9662

I would do this in the current situation. Hope this helps you. As the hyperlink is part of the form input so I will keep it together instead of putting it inside another form-group.

.form__side__hyperlink {
  position: absolute;
  left: 100%;
  bottom: 10px;
  /* or bottom 0 if you want it on the bottom */
  white-space: nowrap;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">

  <div class="form-group col-xs-4">
    <label class="form__label" for="form__field__recipientId">Código  beneficiario </label>
    <input class="form-control input-md col-xs-8" id="form__field__recipientId" name="form__field__recipientId" type="text" placeholder="Introduce ordenante">
    <a class="form__side__hyperlink p-t-20" href="">Buscar beneficiario</a>

  </div>

</div>

Upvotes: 1

Abin Thaha
Abin Thaha

Reputation: 4633

I hope this might help you.

.row {
    display: flex;
    align-items: flex-end;
}

But instead of giving it to the .row, give it another class name and apply the styles to that particular class only.

Upvotes: 1

Related Questions