Skip to content

Instantly share code, notes, and snippets.

@andrempeixoto
Created June 16, 2021 20:28
Show Gist options
  • Save andrempeixoto/7411c767fcd8f8071e286322453e5d99 to your computer and use it in GitHub Desktop.
Save andrempeixoto/7411c767fcd8f8071e286322453e5d99 to your computer and use it in GitHub Desktop.
<form action="" method="get">
<input type="text" name="search" required="required" placeholder="type here"/>
<input type="reset" value="" alt="clear" />
</form>
<style>
input[type="text"]
{
height: 38px;
font-size: 15pt;
}
input[type="text"]:invalid + input[type="reset"]{
display: none;
}
input[type="reset"]
{
background-image: url( https://img.icons8.com/windows/32/000000/macos-close.png );
background-position: center center;
background-repeat: no-repeat;
height: .8rem;
width: .8rem;
border: none;
background-color: transparent;
cursor: pointer;
position: relative;
left: -1.8rem;
}
</style>
@andrempeixoto
Copy link
Author

A search field with a 'clear' button when there's content in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment