How to Add Button Inside Input

How to add button inside input

The button isn't inside the input. Here:

input[type="text"] {
width: 200px;
height: 20px;
padding-right: 50px;
}

input[type="submit"] {
margin-left: -50px;
height: 20px;
width: 50px;
}

Example: http://jsfiddle.net/s5GVh/

How i can add a button inside an input box using bootstrap

There is no native bootstrap solutions. You can do this with custom code.

.custom-search {  position: relative;  width: 300px;}.custom-search-input {  width: 100%;  border: 1px solid #ccc;  border-radius: 100px;  padding: 10px 100px 10px 20px;   line-height: 1;  box-sizing: border-box;  outline: none;}.custom-search-botton {  position: absolute;  right: 3px;   top: 3px;  bottom: 3px;  border: 0;  background: #d1095e;  color: #fff;  outline: none;  margin: 0;  padding: 0 10px;  border-radius: 100px;  z-index: 2;}
<div class="custom-search">  <input type="text" class="custom-search-input" placeholder="Enter your email">  <button class="custom-search-botton" type="submit">Subscribe</button>  </div>

Button inside input (HTML/CSS)

* {
box-sizing: border-box;
}

input {
background: #8196aa;
border: 0;
border-radius: 10px;
color: white;
padding: 20px;
width: 100%;
}

input:focus {
outline: none;
}

input::placeholder {
color: white;
}

button {
background: #16bdae;
border: 0;
border-radius: 7px;
color: white;
padding: 15px;
position: absolute;
right: 5px;
top: 5px;
}

.pt-site-footer__submit {
position: relative;
display: inline-block;
width: 50%;
}
<div class="pt-site-footer__submit">
<input type="email" placeholder="Your e-mailadress" />
<button>LOGIN</button>
</div>

How to add button inside input field

They have different border radius - the button and the input. How could they be perfect match? Also different height.
As for the "hint" line, just place it under in it's own div.
I've tweaked a little your example using float:left and some adjustments. It's not perfect implementation but looks ok. Note height + padding = 48px.

.my-input-group {
position: relative;
}

.left input {
background-color: transparent;
border: 1px solid hsl(0, 36%, 70%);
border-radius: 15px;
padding: 13px;
padding-right: 113px;
width: 60%;
height: 22px;
float: left;

}

.left button {
background-image: linear-gradient(135deg, hsl(0, 80%, 86%), hsl(0, 74%, 74%));
border: 1px solid transparent;
border-radius: 15px;
width: 100px;
height: 48px;
float: left;
position: relative;
left: -101px;
top: 1px;
}

.left .error {}

my-input-group
<form action="#" class="left">
<div class="my-input-group">
<input type="text" placeholder="Email Address">

<button type="submit"><img src="/images/icon-arrow.svg "></button>
<div style="clear:both"></div>
<div class="error">
<small>please provide a valid Email</small>
</div>
</div>
</form>

<img src="/images/icon-error.svg" alt="Sample Image" class="error">

How can i place submit button inside input field in Bootstrap

add to this css

.mycustom {
border: solid 1px green;
position: relative;
}
.mycustom input[type=text] {
border: none;
width: 100%;
padding-right: 123px;
}
.mycustom .input-group-prepend {
position: absolute;
right: 4px;
top: 4px;
bottom: 4px;z-index:9;
}

with one css mycustom class in your input-group class

like this

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"><style>.mycustom {border: solid 1px green;position: relative;}.mycustom input[type=text] {border: none;width: 100%;padding-right: 123px;}.mycustom .input-group-prepend {position: absolute;right: 4px;top: 4px;bottom: 4px;z-index:9;}</style><form>  <div class="col-lg-10 mb-3">    <div class="input-group mycustom">      <input type="text" class="form-control rounded-0" id="validationDefaultUsername" placeholder="Username" aria-describedby="inputGroupPrepend2" required>      <div class="input-group-prepend">        <input type="submit" vlaue="submit" class="btn btn-primary btn-sm rounded-0" id="inputGroupPrepend2">      </div>    </div>  </div></form>

How to add a button inside a input field

use this code

css:-

.fixed-bottom2 {
box-shadow: inset 0px 4px 5px #ededed;
padding: 9px;
margin: -20px !important
}

.sent-message-text {
border: 1px solid;
margin: 10px 0px 10px 15px;
min-height: 36px;
border-radius: 4px;
width: 100%;
position: relative;
}

.post-image-uploaad {
position: relative;
width: auto;
height: 22px;
margin: -39px -3px 1px 1px;
float: right;
}

.no-button-design {
padding: 0px;
border: 0px;
background-color: transparent;
margin: 19px 35px;
}

.no-button-design img {
height: 34px;
}

html:-

<div>
<div style="float: left;width: 82%">
<input type="text" class="sent-message-text">
<img src="../img/camera.png" class="post-image-uploaad">
</div>
<div>
<button class="no-button-design"><img src="../img/msg-sent.png" class="post-image-uploaad_send" style="margin-right: 15px;"></button>
</div>
</div>
</div>

Add button inside Input field ReactJS

Just a simple code snippet, how you can achieve what you are asking :


.inputWithButton {  position: relative;  height: 100px;  width : 200px;}
.inputWithButton input{ width: 70%; height: 25px; padding-right: 60px;}
.inputWithButton button { position: absolute; right: 0; top : 5px;}
<div class='inputWithButton'>  <input type="text"/>  <button>Search</button></div>

Bootstrap button inside input-group

If you follow bootstrap's documentation:

<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<i class="fa fa-search"></i>
</button>
</span>
</div>

Place button inside input form with flex

I have changed some properties in your code based on your requirement. Chcek the snippet below. The button will be inside the input on desktop and it will be stacked in mobile (Under 567px).

And a few changes I did in your code includes:

  • There was style for .button which wasn't present
  • There was style for #url-25 which was also not there.
  • Input submit changed to button submit.
  • Removed unnecessary !importants.

* {
box-sizing: border-box;
}

html, body {
margin: 0;
}

#form {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
position: relative;
}

button {
font-size: 16px;
border-radius: 50px;
position: absolute;
padding: 10px;
right: 0;
height: 100%;
}

input {
width: 100%;
border-radius: 50px;
padding: 10px;
}

input:focus {
outline: none;
box-shadow: none;
border: 0;
}

@media (max-width: 567px) {
#form {
flex-direction: column;
}
button, input {
position: static;
width: 100%;
border-radius: 0;
}
}
<form id="form">
<input type="text" name="name" placeholder="text">
<button type="submit">BUILD YOUR APP</button>
</form>


Related Topics



Leave a reply



Submit