This is probably simple but I dont know how to do it. Currently with this code the "find" button sits on the line below the input "location" box. How do I get it to sit on the same line to the right like most search boxes work?
HTML
<div class="fieldwrapper">
<input id="field_location" class="field r2" placeholder="Town, City or Postcode" id="Postcode" name="Postcode" type="text" value=""><input type="submit" id="findbutton" value="Find" />
</div>
CSS
field { font-family:arial, sans-serif; border-color: #d9d9d9; border-top:solid 1px #c0c0c0; }
input.field{width:100%}
Link http://jsfiddle.net/VL3Dj/
Using float and overflow attributes: Make a label and style it with float attribute. Now set the label float(position) left or right according to your requirement. This will align your label accordingly. Overflow property for input is used here to clip the overflow part and show the rest.
To link a submit button to another webpage using HTML Form Tags: Using the HTML Form's Action Attribute, we can link the submit button to a separate page in the HTML Form element. Here, declare/write the “Submit button” within HTML Form Tags and give the File Path inside the HTML form's action property.
To get all elements to appear on one line the easiest way is to: Set white-space property to nowrap on a parent element; Have display: inline-block set on all child elements.
HTML Break (<br>) Tag If you want to prevent a line break between two words, use a non-breaking space. If you want to insert a line break, use the HTML break tag, written as <br>. You don't need a closing tag here — just writing <br> adds a line break.
If you want your text box to be 100% width
and a button besides it you can do it like this : My Fiddle
<input type="submit"value="Find" style="float: right" />
<div style="overflow: hidden; padding-right: .5em;">
<input type="text" style="width: 100%;" />
</div>
............Demo
Hi now add this css
.fieldwrapper{
white-space: nowrap;
}
Live demo
You only need to know the width of the button for it to work. Then you basically give the input a full width and position absolute the button to the right. The padding is so no text sits behind the button:
<form method="post" action="">
<input type="text" name="search-str" id="search-str" value=""/>
<button type="submit">Submit</button>
</form>
As for the CSS:
form {
position: relative;
}
input {
width: 100%;
padding-right: 40px;
}
button {
width: 40px;
position: absolute;
top: 0;
right: 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With