Reputation: 755
I have this http://jsfiddle.net/Gqufq/ and I want to position the second input right after (in the same line) of the first and end it to the right of the div.
How to do this with CSS, without put an explicit dimension on the first input? (Also, the div may have a variable width)
div { width: 200px; background-color: gray; }
<div>
<input size="5" />
<input />
</div>
Upvotes: 0
Views: 84
Reputation: 106008
The use of float technic and labels will do it: http://jsfiddle.net/H3YQ3/1/ , http://jsfiddle.net/H3YQ3/2/
div {
width: 200px;
background-color: gray;
margin:1em;
}
label {
display:block;
overflow:hidden;
}
label:first-child {
float:left;
width:50px;
}
input {
display:block;
width:100%;
box-sizing:border-box;
}
.big {
width:400px;
}
Upvotes: 0
Reputation: 8981
try this
div { width: 200px;
background-color: gray;
display:inline;
padding:5px; }
Upvotes: 2