Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望 HTML 中的元素相对于它的父元素定位,类似于这个问题,但使用内联。
我有一个小提琴要演示。对于此示例,我希望文本框覆盖文本(使用margin:0;,而不是负值。
margin:0;
可以做到吗?
尝试使用position:relative;并position: absolute;喜欢这样:
position:relative;
position: absolute;
我的小提琴
或者只是使用left: 0px;而不是,margin但要确保父母div是positioned relative
left: 0px;
margin
div
positioned
relative
<div> <input value="Text" /> </div>
还是您将其用于输入以外的其他用途?
由于您已经在使用绝对定位,您可以只做left: 0.
left: 0