Пожалуйста, обратитесь к следующему примеру, вы можете добавить тег <span>
вне элементов ввода. Затем добавьте псевдоэлемент к тегу <span>
.
<span class="input-icon">
<input type="text" class="input" value="" placeholder="name" />
</span>
Затем используйте следующий стиль CSS:
<style>
.input {
background: none;
border-radius: 3px;
border: 1px solid;
box-sizing: border-box;
cursor: pointer;
font-size: 20px;
line-height: normal;
padding: 1em 2em 1em 3em;
text-transform: uppercase;
}
input :hover, :focus {
background: rgba(0,0,0,.05);
}
.input-icon {
display: inline-block;
position: relative;
}
.input-icon::before {
background: url(http://www.scottohara.me/assets/img/scott.jpg) no-repeat center center;
background-size: 100% auto;
content: '';
pointer-events: none;
height: 100%;
left: .5em;
position: absolute;
top: 0;
width: 2em;
}
</style>
Вывод, как показано ниже: