Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put a button inside the text box

Tags:

html

css

I'm trying to design a form, with a button inside a text-box. I want that button to be inside the text-box. This is how I tried:

<div class="row">
    <div class="col-sm-6">
        <div class="form-group required">
            <label for="PickList_Options" class="col-sm-4 control-label">Options</label>
            <div class="col-sm-4 buttonwrapper">
                <input type="text" class="form-control" id="PickList_Options" name="PickList_Options" value='' />
                <button>GO</button>
            </div>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="result" id="mydiv"></div>
    </div>
</div>

my css:

.buttonwrapper {
    display:inline-block;
}

input,
button {
    background-color:transparent;
    border:0;
}

But, the problem is, the Go button is placed below the text-box. What should I do to place it inside the text-box?

Simple Image

I want that "Go" button to be inside the text-box.

like image 592
SSS Avatar asked Nov 09 '16 09:11

SSS


2 Answers

Please try this. Remove the outline for the input in active and focus state, and add a border for the input container.

Edit: Im adding the flex-box implementation as well.

  1. Display inline-block implementation

.input-container{
    width: 250px;
    border: 1px solid #a9a9a9;
    display: inline-block;
}
.input-container input:focus, .input-container input:active {
    outline: none;
}
.input-container input {
    width: 80%;
    border: none;
}

.input-container button {
    float: right;
}
<div class="input-container">
    <input type="text" class="input-field"/>
    <button class="input-button">Ok</button>
</div>
  1. Display flex implementation

.input-container {
    display: flex;
    width: 250px;
    border: 1px solid #a9a9a9;
    justify-content: space-between;
}
.input-container input:focus, .input-container input:active {
    outline: none;
}
.input-container input {
    border: none;
}
<div class="input-container">
    <input type="text" class="input-field"/>
    <button class="input-button">Ok</button>
</div>
like image 72
Nitheesh Avatar answered Sep 20 '22 12:09

Nitheesh


.buttonwrapper {
  display: inline-block;
}

input{
  background-color: transparent;
  border: 2px solid black;
}

button {
  margin-left: -50%;
  border: none;
  background-color: transparent;
}
<div class="row">
  <div class="col-sm-6">
    <div class="form-group required">
      <label for="PickList_Options" class="col-sm-4 control-label">Options</label>

      <div class="col-sm-4 buttonwrapper">
        <input type="text" class="form-control" id="PickList_Options" name="PickList_Options" value='' />
        <button>GO</button>
      </div>
    </div>
  </div>
  <div class="col-sm-6">
    <div class="result" id="mydiv"></div>
  </div>
</div>
like image 42
Federico Avatar answered Sep 21 '22 12:09

Federico