Why is the input box not using the specified CSS styles for the input and label tags? The transform property doesn't seem to be working as expected. I've highlighted the areas where I'm facing issues with bold text, and I've included both my CSS and HTML code below.
Here's the code I tried:
.main {
display: flex;
flex-direction: column;
height: 400px;
width: 200px;
margin: auto;
border: 2px solid black;
align-items: center;
justify-content: center;
}
.searchdiv {
position: relative;
width: 100%;
/* border: 2px solid red; */
}
.search {
width: 100%;
border: 0px;
border-bottom: rgba(22, 22, 22, 0.349);
background: rgba(211, 210, 210, 0.705);
}
label {
position: absolute;
top: 0%;
left: 0%;
transition: 0.3s ease;
}
.search:focus,
.search:valid {
outline: none;
background-color: rgba(85, 206, 247, 0.699);
}
#searchbar:focus~label,
#searchbar:valid~label {
transform: translatey(-10px);
}
<div class="main">
<div class="searchdiv">
<input type="text" id="searchbar" class="search"><label for="searchbar">Search</label>
</div>
<div><button class="btn srchbtn">SEARCH</button></div>
</div>