css - HTML&CSS-如何在文本框中更改图像背景

标签 css html

如何更改文本框标签的背景,当前我的文本框上有图像。

enter image description here

如您所见,文本框的右上角有一个二维码图像,我想对其进行更改。假设我希望此图像img/captureicon.png替换当前图像。

我试图更改它,但是它不起作用或什么也没显示。

这是如上所示的图像文本框的代码。

.qrcode-text-btn {
  display:inline-block; background:url(//dab1nmslvvntp.cloudfront.net/wp-content/uploads/2017/07/1499401426qr_icon.svg) 50% 50% no-repeat; height:30px; width:40px; margin-top:8px; margin-left:-40px; cursor:pointer
}


我尝试将其更改为此,但没有用。

.qrcode-text-btn {
  display:inline-block; background:url(img/captureicon.png) 50% 50% no-repeat; height:30px; width:40px; margin-top:8px; margin-left:-40px; cursor:pointer
}


我完整的CSS代码

    <style type="text/css">
    body, input {
      font-size:14pt
    }

    input, label {
      vertical-align:middle
    }

    .qrcode-text {
      padding-right:1.7em; margin-right:0
    }

    .qrcode-text-btn {
      display:inline-block; background:url(//dab1nmslvvntp.cloudfront.net/wp-content/uploads/2017/07/1499401426qr_icon.svg) 50% 50% no-repeat; height:30px; width:40px; margin-top:8px; margin-left:-40px; cursor:pointer
    }

    .qrcode-text-btn > input[type=file] {
      position:absolute; overflow:hidden; width:1px; height:1px; opacity:0
    }

  </style>


这是我的html代码,用于结束文本框和文本框的内部图像。

 <input type=text size=16 placeholder="Tracking Code" id="qrcid" name="qrid" class=qrcode-text>
          <label class=qrcode-text-btn>
            <input type=file accept="image/*" capture=environment onclick="return showQRIntro();" onchange="openQRCamera(this);" tabindex=-1>
          </label> 

最佳答案

我猜无法从image / capture icon.png加载图像,因为如果您将绝对URL放入CSS,则会显示该图像。

   .qrcode-text-btn {
   display:inline-block; background:url(/image/qhAwK.png) 50% 50% 
   no-repeat; height:30px; width:40px; margin-top:8px; margin-left:-40px; 
   cursor:pointer
    }

因此,请检查您的图像以及文件名和路径。

关于css - HTML&CSS-如何在文本框中更改图像背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55898343/

相关文章:

css - CSS中的位置

javascript - Onsen-ui:ons-button 提交不提交表单

html - 子菜单的下拉菜单位置

html - firefox 我的 td 文本没有在单元格中间对齐

css 属性不影响 <li> joomla 3.6 中的 <a> 链接

javascript - 手机版视频背景不完整

javascript - 我正在尝试用 html 和 javascript 制作一个简单的 tic tac toe 游戏

jquery - 单击时替代 SVG 填充颜色

html - 为什么谷歌要使用字体标签?

javascript - 如何创建仅在单击按钮时出现的黑色幕布?