Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
创建一个容器,并将
position
CSS 属性设置为relative
,以便任何内部绝对定位元素都是相对于容器的。还要添加display:inline-block
,以便容器缩小到所需的最小尺寸(=输入字段的尺寸)。然后,将
padding-right:42px
添加到密码字段,以便按钮不会与字段内容重叠。最后,添加position:absolute; right:0;
到锚点,以便它位于输入字段的右侧。小提琴: http://jsfiddle.net/LyfTJ/1/
HTML:
JS:
CSS:
Create a container, and set the
position
CSS attribute torelative
, so that any inside absolutely-positioned element is relative to the container. Also adddisplay:inline-block
, so that the container shrinks to the minimum required size (=the size of the input field).Then, add a
padding-right:42px
to the password field, so that the button does not overlap the contents of the field. Finally, addposition:absolute; right:0;
to the anchor, so that it's positioned at the right side of the input field.Fiddle: http://jsfiddle.net/LyfTJ/1/
HTML:
JS:
CSS: