JNF
JNF

Reputation: 3730

Position Inline Element Relative to Container

I want an element in HTML to be positioned relative to it's parent, similar to this question, but using inline.

I have a fiddle to demonstrate. For this example, I would like the textbox to cover the text (using margin:0;, not a negative value.

Can it be done?

Upvotes: 2

Views: 7646

Answers (2)

Mr. Alien
Mr. Alien

Reputation: 157294

Try using position:relative; and position: absolute; like this :

My Fiddle

Or just use left: 0px; instead of margin but make sure that the parent div to be positioned relative

Upvotes: 3

Chad
Chad

Reputation: 5408

<div>
    <input value="Text" />
</div>
​

Or are you using this for something other than inputs?

Since you're already using absolute positioning, you could just do left: 0.

Upvotes: 0

Related Questions