Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在文本区域中的占位符前添加图标_Html_Css - Fatal编程技术网

Html 如何在文本区域中的占位符前添加图标

Html 如何在文本区域中的占位符前添加图标,html,css,Html,Css,我想在文本区域中的占位符前面添加一个图标,但不知道怎么做。 这是我的密码: <div class="center-part"> <div class="user-input"> <textarea class="share" name="share" type="text" placeholder=""> </textarea> </div> </div>

我想在文本区域中的占位符前面添加一个图标,但不知道怎么做。 这是我的密码:

<div class="center-part">
  <div class="user-input">
    <textarea class="share" name="share" type="text" 
         placeholder=""> 
    </textarea>
  </div>            
</div>


谢谢。

不可能在占位符中组合图标和文本。因为您只能在其中使用1种字体。如果您可以在占位符中使用不同的字体,则可以使用

通过执行以下操作,可以添加一个范围(位于文本区域内)并将占位符移到图标右侧:

HTML(在代码中添加了span):


您可以在

Probable Duplicate(可能重复)-简单:将图标用作输入/文本区域的背景图像,并将其放置在您想要的位置。然后,使用填充来确保文本不在您的ICON中可能的副本
<div class="center-part">
  <div class="user-input">
     <textarea class="share" name="share" type="text" placeholder="&emsp;&emsp;Icon before this"></textarea>
<span class="icon"></span>
  </div>            
</div>
.center-part {
  position: relative;  
  min-height: 50px;
  min-width: 200px;
}

.share {
  min-height: 50px;
  min-width: 200px;
}

.icon {
  position: absolute;
  background: red;
  width: 15px;
  height: 15px;
  left: 10px;
  top: 5px;
}