0

I have a box inside bootstrap input and link inside.But below as you can see,input isn't full width.How can I make it full?

enter image description here

You can see there's gap between input and link.I want to make that gap instead of input width.

.resetToDef{
  display: block;
  width:25.8%;
  min-width: 178px;
  border-radius: 4px;
  border: 1px solid #FF7921;
}


 .resetToDef a{
  font-size:12px;
  color:#FF7921;
  border: none;
  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="30" id="times-perform" name="times-perform">
                    <a href="" class="float-right btn"> Back to default</a>
                  </div> 
Timuçin Çiçek
  • 1,516
  • 3
  • 14
  • 39
  • Do you want the input field to take up the entire width of the ``
    ``, or do you want it to take up all the space to the left of the link?
    – kmoser Mar 02 '20 at 06:59
  • update `.resetToDef input { display: inline-block; width: 80%; border: none; }` – PHP Ninja Mar 02 '20 at 07:00
  • Does this answer your question? [How can I put an input element on the same line as its label?](https://stackoverflow.com/questions/6938900/how-can-i-put-an-input-element-on-the-same-line-as-its-label) – Awais Mar 02 '20 at 07:39

5 Answers5

1

Just utilize the built in bootstrap class for form input group input-group.

.resetToDef{
  display: block;
  width:25.8%;
  min-width: 178px;
  border-radius: 4px;
  border: 1px solid #FF7921;
}


 .resetToDef a{
  font-size:12px;
  color:#FF7921;
  border: none;
  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-group">
                    <input type="number" class="form-control" placeholder="30" id="times-perform" name="times-perform">
                    <a href="" class="float-right btn"> Back to default</a>
                  </div>
Ahmad
  • 12,336
  • 6
  • 48
  • 88
0

Can be something like this:

.resetToDef{
  display: block;
  width:100%;
  min-width: 178px;
  border-radius: 4px;
  border: 1px solid #FF7921;
}


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

.resetToDef input{
 display:inline-block;
 width:80%;
 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="30" id="times-perform" name="times-perform">
                    <a href="" class="float-right btn"> Back to default</a>
                  </div>
ROOT
  • 11,363
  • 5
  • 30
  • 45
0

Remove width given to the input element and make resetToDef display flex.

.resetToDef{
  display: flex;
  width:25.8%;
  min-width: 178px;
  border-radius: 4px;
  border: 1px solid #FF7921;
  justify-content: space-between;
}


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

.resetToDef input{
 display:inline-block;
 
 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="30" id="times-perform" name="times-perform">
                    <a href="" class="float-right btn"> Back to default</a>
                  </div> 
0

You can use flex and flex grow to achieve that.

.resetToDef {
    display: flex;
}

.resetToDef input {
    flex-grow: 1;
}

What this will do is set the parent to be a flex container so that direct children can use the flex properties.

Now we set the input to be 'flex-grow: 1;', that will tell the input to "grow" (take up what available space remains) and be full available width.

Don't forget that your elements have padding which can seem like the elements don't take the full available width.

Buttered_Toast
  • 901
  • 5
  • 13
0

.resetToDef - display:flex; and input - flex:1;

this will work for you.

.resetToDef {
  display: flex;
  width: 25.8%;
  min-width: 178px;
  border-radius: 4px;
  border: 1px solid #FF7921;
}

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

.resetToDef input {
 flex:1;
  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="30" id="times-perform" name="times-perform">
  <a href="" class="float-right btn"> Back to default</a>
</div>
Heena Vora
  • 300
  • 4
  • 16