open
25.09.2022.

Search form example

This code snippet, when pasted into the sidebar, will display a search form.

The lower part of the code controls the design, put this in the main css file of the template. Live demo in the sidebar.

/// search form
<form method="get" id="searchform" action="<?php bloginfo("url"); ?>/">
<fieldset class="search">
<input value="search here" onfocus="if(this.value==this.defaultValue)this.value=&#39;&#39;;" onblur="if(this.value==&#39;&#39;)this.value=this.defaultValue;" id="s" name="s" type="text"/>
<button>Search</button>
</fieldset>
</form>
/// css example
<style type="text/css">
fieldset.search {
border: none;
max-width: 100%;
margin: 0px 0 40px 0;
}
.search input, .search button {
border: none;
float: left; font-size: 10px;
}
.search input{
color: rgba(0,0,0,0.3);
width: calc(75% – 25px);
padding: 10px 10px;
background-color: rgba(0,0,0,0.1);
margin: 0 5px 0 0;
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
}
.search input:focus {
background-color: rgba(0,0,0,0.7);
outline: none;
color: #FFFFFF;
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
}
.search button{
width: calc(25% – 20px);
padding: 10px;
cursor: pointer;
background-color: rgba(215,124,97,1);
background-image: url("data:image/svg+xml;charset=utf8,%3C?xml version=’1.0′ encoding=’UTF-8′ standalone=’no’?%3E%3C!DOCTYPE svg PUBLIC ‘-//W3C//DTD SVG 1.1//EN’ ‘http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd’%3E%3Csvg version=’1.1′ id=’Layer_1′ xmlns=’http://www.w3.org/2000/svg’ xmlns:xlink=’http://www.w3.org/1999/xlink’ x=’0px’ y=’0px’ width=’150px’ height=’150px’ viewBox=’0 0 150 150′ enable-background=’new 0 0 150 150′ xml:space=’preserve’%3E%3Cimage id=’image0′ width=’150′ height=’150′ x=’0′ y=’0′ href=’data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAQAAACWCLlpAAAABGdBTUEAALGPC/xhBQAAACBjSFJN AAB6JgAAgIQAAP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wz0zamZDlcC1lKw9tBOe/7cla0+L++i/ZUytXJcs SlNiS4/82mTtmxLh+csnzpqb63pnHQh9G5krIq6vZAGhb+MLe6Bm8c5w7m52wvTFdVbDAzX6szH/ pDU211kNDwwo8eP4un/GfdqB+9ddsoS57pIljMkiYLIImCwCJouAySJgsgiYLAImi4DJImCyCJgs AiaLgMkiYLIImCwCJouAySJgsgiYLAImi4DJImCyCJgsAiaLgMki8B+Ahiop7kx+9wAAABZ0RVh0 Q3JlYXRpb24gVGltZQAwNy8xNi8xNaoAakwAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMDctMjBU MjM6MjI6NTcrMDA6MDAxtEWLAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTA3LTIwVDIzOjIyOjU3 KzAwOjAwQOn9NwAAABN0RVh0ZGM6Zm9ybWF0AGltYWdlL3BuZ/+5Gz4AAAAcdEVYdFNvZnR3YXJl AEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAAAI3RFWHR4bXA6Q3JlYXRlRGF0ZQAyMDE1LTA3LTE1 VDIzOjI5OjE3WnVH/BcAAAAtdEVYdHhtcDpDcmVhdG9yVG9vbABBZG9iZSBGaXJld29ya3MgQ1M2 IChXaW5kb3dzKShj88kAAAAjdEVYdHhtcDpNb2RpZnlEYXRlADIwMjEtMDItMjRUMDE6MjI6MDFa ftyD+AAAAABJRU5ErkJggg==’/%3E%3C/svg%3E");
background-size: 20px auto;
background-repeat: no-repeat;
background-position: center center;
color: transparent;
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
}
.search button:hover {
background-size: 30px auto;
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
}
</style>
Copy to Clipboard

Related posts

Got a question? Is something not working? Write and I'll answer!

Leave a Reply

Your email address will not be published. Required fields are marked *