代码之家  ›  专栏  ›  技术社区  ›  koque

在输入元素背景中设置图像无效

  •  0
  • koque  · 技术社区  · 9 年前

    我试图在输入元素中设置图像,但图像没有显示。

    html:

        <div class="col-md-12">
            <input class="form-control ccnumber" type="text" id="creditCardNo" 
              formControlName="creditCardNo">
        </div>
    

    .ccnumber {
        background-image: url("creditcard.png");
        background-repeat: no-repeat;
        background-position: left;
        background-attachment: fixed;
    }
    
    1 回复  |  直到 9 年前
        1
  •  2
  •   Suren Srapyan    9 年前

    检查图像的路径。你的代码运行良好。检查你的网络,看看为什么没有加载。

    .ccnumber {
        background-image: url("https://www.w3schools.com/css/img_fjords.jpg");
        background-repeat: no-repeat;
        background-position: left;
        background-attachment: fixed;
    }
    <div class="col-md-12">
        <input class="form-control ccnumber" type="text" id="creditCardNo" 
             formControlName="creditCardNo">
    </div>