2

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?

Community
  • 1
  • 1
JNF
  • 3,696
  • 3
  • 31
  • 64

2 Answers2

3

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

Mr. Alien
  • 153,751
  • 34
  • 298
  • 278
0
<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.

Chad
  • 5,308
  • 4
  • 24
  • 36