1

I'm trying to make a box which has input alligned left and link alligned right.But link is always on the left as default as you can see on the below

enter image description here

Here what I expect below

enter image description here

I tried float:right but it puts the link on the top right corner which I dont prefer.I can use margin-left and top to make it alligned which would be not good practise.Also when I shrink the page I want to keep its position.

.resetToDef{
  display: block;
  width:400px;
  border-radius: 4px;
  border: 1px solid #FF7921;
}


 .resetToDef a{
  font-size:12px;
  color:#FF7921;
  text-decoration-line: underline
}


.resetToDef input{
 display:inline-block;
 width:57px;
 border:none;
} 
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

        <div class="resetToDef">
                  <input type="number" class="form-control" placeholder="5" id="shift-task-times-perform" name="shift-task-times-perform">
                    <a href="" > Back to original</a>
                  </div> 
Timuçin Çiçek
  • 1,516
  • 3
  • 14
  • 39

1 Answers1

0

Simply add float-right to link,

Like <a href="" class="float-right"> Back to original</a>

.resetToDef {
  display: block;
  width: 400px;
  border-radius: 4px;
  border: 1px solid #FF7921;
}

.resetToDef a {
  font-size: 12px;
  color: #FF7921;
  text-decoration-line: underline
}

.resetToDef input {
  display: inline-block;
  width: 57px;
  border: none;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<div class="resetToDef">
  <input type="number" class="form-control" placeholder="5" id="shift-task-times-perform" name="shift-task-times-perform">
  <a href="" class="float-right btn"> Back to original</a>
</div>

Method 2:

You can use bootstrap input group which is easier inbuilt bootstrap solution.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<div class="input-group mb-3">
  <input type="number" class="form-control border-right-0" placeholder="5" id="shift-task-times-perform" name="shift-task-times-perform">
  <div class="input-group-append">
    <span class="input-group-text bg-white" id="basic-addon2"><a href="">Back to original</a></span>
  </div>
</div>
sanoj lawrence
  • 951
  • 5
  • 29
  • 69