I’m trying to place an icon inside an input in html. I have the code below but I can’t get the image to show. I know the path to the image is correct so I can’t find what is wrong here.
My objective is so that the icon appears on the left side of the input, "glued" to the left border.cand the placeholder appears after the icon.
<input type="text" class="login" id="username" placeholder="Username" required>
.login {
border-radius: 10px;
border: none;
width: 30%;
display: block;
text-indent: 3rem;
}
#username {
background-image: url(../wwwroot/images/login-user.png);
background-repeat: no-repeat;
background-position: 2px 3px;
}
2
Answers
If you assume that you know that your image path is correct, try once just an image-tag to see if it displays. Use an Image-Tag to cros-check this.
To solve your problem you can try something like this:
“’
This is quiet simple to archive with some HTML/CSS
https://codepen.io/aeolous/pen/Exrpxwv
The HTML
The CSS