[英]Position an icon inside textarea
I am trying to position an icon that should clear the textarea
content.我正在尝试 position 一个应该清除
textarea
内容的图标。 I have a sample I worked on, wrapped the textarea with a parent that has display: inline-block
but the problem is that I want the textarea/parent to be full width to begin with.我有一个我处理的示例,用一个具有
display: inline-block
的父级包裹了 textarea,但问题是我希望 textarea/parent 开始时是全宽的。 If I set a 100% width on textarea, it does not achieve the desired result.如果我在 textarea 上设置 100% 的宽度,它不会达到预期的效果。 Also, can't work with
vw
which seems to work apparently, for some reason people at work avoid it.此外,不能与似乎工作的
vw
一起工作,出于某种原因,工作中的人会避免它。
Here's what I have这就是我所拥有的
https://codesandbox.io/s/magical-haze-ncslb?file=/src/styles.css https://codesandbox.io/s/magical-haze-ncslb?file=/src/styles.css
You need to either change .parent
class to display:block
or add the 2 lines width: 100%; box-sizing: border-box;
您需要将
.parent
class 更改为display:block
或添加 2 lines width: 100%; box-sizing: border-box;
width: 100%; box-sizing: border-box;
in css as demonstrated below:在 css 中,如下所示:
.parent { border: 1px solid #ccc; padding: 5px 10px; display: inline-block; position: relative; width: 100%; //Add this line box-sizing: border-box; //Add this line }.parent span { position: absolute; right: 10px; top: 6px; background-color: #ddd; }.parent textarea { border: none; width: 100%; display: block; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.