移动删除输入文本框中的毛法



我希望将glyphicon-remove放在输入文本框的右端,这是我的代码 -

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body{
  position: relative;
  background-color: rgba(0,0,0,0.9);
  height: 100vh;
}
.content{
  text-align: center;
  position: absolute;
  width: 100%;
  top: 50%;
  left: 50%;
  transform:translate(-50%,-50%);
}
.fill_text{
  width: 20%;
  height: 42px;
  background-color: #DDD;
  border-radius: 20px;
  font-size: 20px;
  padding: 10px;
  border: 5px solid #E35F14;
  margin: 10px auto;
  outline: 0;
  position: relative;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
  <div class="content">
  <input type="text" class="fill_text">
    <span class="glyphicon glyphicon-remove"></span>
  </input>
  </div>

我将输入文本框的位置设置为相对,我尝试将删除图标的位置作为绝对值,但这不起作用。你能告诉我为什么不起作用吗?

<input>元素中不允许元素。

添加此CSS

  .glyphicon-remove{
      position: absolute;
      top: 50%;
      right: 30px;
      z-index:10;
    }

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body{
  position: relative;
  background-color: rgba(0,0,0,0.9);
  height: 100vh;
}
.content{
  text-align: center;
  position: absolute;
  width: 100%;
  top: 50%;
  left: 50%;
  transform:translate(-50%,-50%);
}
.fill_text{
  width: 20%;
  height: 42px;
  background-color: #DDD;
  border-radius: 20px;
  font-size: 20px;
  padding: 10px;
  border: 5px solid #E35F14;
  margin: 10px auto;
  outline: 0;
  position: relative;
  
}
.glyphicon-remove{
  position: absolute;
  top: 50%;
  right: 30px;
  z-index:10;
  cursor:pointer;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
  <div class="content">
  <input type="text" class="fill_text"/>
    <span class="glyphicon glyphicon-remove"></span>
  </div>

最新更新