How to have an image placeholder in angularjs

前端 未结 1 1590
失恋的感觉
失恋的感觉 2021-01-14 07:25

I have a search input box and currently when it is not selected it shows Search here but instead of text can I have an image?

1条回答
  •  有刺的猬
    2021-01-14 08:07

    You can do it directly using css

    input#autoComplete {
        background-image: url(https://cdn1.iconfinder.com/data/icons/hawcons/32/698627-icon-111-search-16.png);
        background-position: 10px center;
        background-repeat: no-repeat;
        border: 1px solid #ccc;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        -ms-border-radius: 4px;
        -o-border-radius: 4px;
        border-radius: 4px;
        padding: 10px 5px;
        text-indent: 20px;
        -webkit-transition: all 0.2s;
        -moz-transition: all 2s;
        transition: all 0.2s;
    }
    input#autoComplete:focus {
        background-position: -20px center;
        text-indent: 0;
    }
    

    Check this plunker

    In case if you want text also do not remove placeholder="Search" from your input

    0 讨论(0)
提交回复
热议问题