.search {
margin: 10px;
}
.search::before {
content: "";
position: absolute;
top: 50%;
bottom: auto;
width: 20px;
height: 20px;
transform: translateY(-50%);
background: url('magnifying-glass.svg');
}
input[type="search"] {
height: 30px;
padding-left: 30px;
border: none;
border-radius: 0.25rem;
outline: none;
}
.container {
position: relative;
background-color: cadetblue;
}
<div class="container">
<div class="search">
<form>
<input type="search" placeholder="Search...">
</form>
</div>
</div>
I have recently started learning css. As per my understanding, I have set a margin of 10px for my input[type="search"]
element within the div.container
by styling the margin
property in the div.search
class. However, it seems like the borders of the input
element and div.container
are not aligning as expected.
Could you please explain what might be causing this issue? I am particularly keen on discovering where my logic is flawed in this scenario.