How do achieve the following:
┌────────────────────parent────────────────────┐ │ label [text-box ] [button] │ │ paragraph │ └──────────────────────────────────────────────┘
label
is aligned to the leftbutton
is aligned to the righttext-box
occupies all remaining width within parentparagraph
is aligned to the left, must be left-aligned with label
tooBoth label
and button
should obey font properties defined elsewhere as maximum as possible. parent
is center-aligned within window, and, naturally, can have arbitrary width.
Please advise.
Use the span. text to fit width of text, and let the input have same size with it by position: absolute to the container.
The size attribute specifies the visible width, in characters, of an <input> element. Note: The size attribute works with the following input types: text, search, tel, url, email, and password. Tip: To specify the maximum number of characters allowed in the <input> element, use the maxlength attribute.
To resize a Textbox within a Contact Form, click Edit on the subquestion in your Build tab. 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.
To resize a shape, text box, or WordArt, under Drawing Tools, on the Format tab, in the Size group, enter the measurements that you want into the Height and Width boxes.
Updated [Oct 2016]: Flexbox version...
form { display: flex; } form input[type="text"] { flex: 1; }
<form> <label>Name</label> <input type="text" /> <button>Submit</button> </form> <p>Lorem ipsum...</p>
Original answer [Apr 2011]: Table-less CSS version (of table behavior)...
<div id="parent"> <div id="inner"> <label>Name</label> <span><input id="text" type="text" /></span> <input id="submit" type="button" value="Submit" /> </div> <p>some paragraph text</p> </div>
CSS...
#inner { display: table; width: 100%; } label { display: table-cell; } span { display: table-cell; width: 100%; padding: 0px 10px; } #text { width: 100%; } #submit { display: table-cell; }
Demo: http://jsfiddle.net/wdm954/626B2/4/
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