I have created an input field like so:
.search-bar {
max-width: 400px;
margin: 20px 50px;
border: none;
}
#searchBarInput {
position: relative;
background: transparent;
padding: 12px 24px;
border-radius: 8px;
border: 2px solid black;
width: 100%;
}
.search-bar__icon {
position: absolute;
height: 100%;
width: 32px;
right: 10px;
top: 5px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
<link href="example.css" rel="stylesheet" />
</head>
<body>
<div class="search-bar" id="searchBar">
<input type="text" placeholder="Search User" id="searchBarInput" />
<i class="material-icons search-bar__icon">search</i>
</div>
</body>
</html>
I am trying to display the search-icon inside the input field. I was really thinking to achieve this with the help of the position-argument, but I didn't: The icon is at the top right corner of my screen. Just as a side note: The input field seems to be larger than 400px as well.