Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place a Button next to a TextBox total 100% width

Tags:

html

css

Is it possible to place a Button next to a TextBox when the Button has a given width (throug it's value) and the Parent div also have a given width. In the end the TextBox width + Button width should be the width of the parent div.

TestExample:

#left
{
    float: left;
    width: 100%;
}
#right 
{
    width: auto;
}
<div>
    <input type="text" id="left"/>
    <input type="button" id="right" value="AnyText"/>
</div>

Thank you!

like image 504
MisterPresident Avatar asked Jul 27 '15 08:07

MisterPresident


People also ask

How do I change the width of a text box?

Go to the Layout tab and adjust the Textbox Width. Within Contact Forms each field will have a different default width. By specifying a larger or smaller value you can increase or decrease the width of the Textbox.

How do I change the width of a textbox in HTML?

This can be done by using the size attribute or by width attribute to set the width of an element. The size attribute works with the following input types: text, search, tel, url, email, and password and not on type date, image, time for these we can use width attribute.


1 Answers

form { display: flex; }
input[type=text] { flex-grow: 1; }
<form>
  <input type="text">
  <input type="button" value="Button text">
</form>
like image 139
nkorth Avatar answered Nov 15 '22 21:11

nkorth