input设置background-image会重复
发布于 5 年前 作者 ujiang 7907 次浏览 来自 问答

* Bug 表现是什么?预期表现是什么?

给input组件设置background-image会出现背景的重复(猜测是渲染后还有个子元素也匹配了background规则)

* 如何复现?

input {
  margin: 10px;
  height: 40px;
  border: 1rpx solid #eee;
  padding-left: 40px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2013%2013'%20enable-background%3D'new%200%200%2013%2013'%3E%3Cg%3E%3Cpath%20fill%3D'%23939398'%20d%3D'M5%2C1c2.2%2C0%2C4%2C1.8%2C4%2C4S7.2%2C9%2C5%2C9S1%2C7.2%2C1%2C5S2.8%2C1%2C5%2C1%20M5%2C0C2.2%2C0%2C0%2C2.2%2C0%2C5s2.2%2C5%2C5%2C5s5-2.2%2C5-5S7.8%2C0%2C5%2C0%20L5%2C0z'%2F%3E%3C%2Fg%3E%3Cline%20stroke%3D'%23939398'%20stroke-miterlimit%3D'10'%20x1%3D'12.6'%20y1%3D'12.6'%20x2%3D'8.2'%20y2%3D'8.2'%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 24px 24px;
}

* 提供一个最简复现 Demo

回到顶部