• Skip to main content
  • Skip to primary sidebar

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network

Do You Like This Site’s Search Bar?

June 28, 2015 By Victor M. Font Jr.

If you haven't checked it out yet, please take a look at this site's search bar. Do you like the show/hide effect? How about the look of the search bar? Personally, I think it nicely complements the look and feel of the Genesis Press Parallax Pro theme.

To accomplish this feature, I added a search form to the Genesis Header through the Genesis Simple Hooks plugin:

Yes, I could have added this directly to my functions.php, but the Simple Hooks plugin makes additions like this very easy.

The look of this search form is created entirely in CSS. There are no graphics used here.

.show-search,
#showsearch {
	padding: 0;
	background-color: transparent;
}

#showsearch {
	font-size: 1.5em;
	position: relative;
	top: -5px;
}

#showsearch:hover {
	color: #05ABE0;
	background-color: black;
}

.search-div {
	float: right;
	margin-bottom: 10px;
}

.search-div .wrap {
	width:440px;
}

::-moz-placeholder {
	color: #999;
	opacity: 1;
	font-weight: 400;
}

::-webkit-input-placeholder {
	color: #999;
	font-weight: 400;
}

.vmf-search-form {
	width: 420px;
	height: 62px;
	background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 50%);
	background-image: -webkit-repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 50%);
	background-image: -moz-repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 50%);
	background-image: -ms-repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 50%);
	background-image: -o-repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 50%);
	background-color: #151515;
	background-size: 6px 6px;
	padding:10px;
	position: relative;
	border-radius: 5px;
	box-shadow: inset 0 31px 0 0 rgba(255,255,255,0.15);
	border: 0.25px solid rgba(255, 255, 255, 0.6);
}

.vmf-search-input {
	width: 296px;
	height: 36px;
	padding: 5px 0px 0px 10px !important;
	background: #1b1b1b; /* Old browsers */
	/* IE9 SVG, needs conditional override of 'filter' to 'none' */
	background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzFiMWIxYiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMyNjI2MjYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
	background: -moz-linear-gradient(top,  #1b1b1b 0%, #262626 100%); /* FF3.6+ */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1b1b1b), color-stop(100%,#262626)); /* Chrome,Safari4+ */
	background: -webkit-linear-gradient(top,  #1b1b1b 0%,#262626 100%); /* Chrome10+,Safari5.1+ */
	background: -o-linear-gradient(top,  #1b1b1b 0%,#262626 100%); /* Opera 11.10+ */
	background: -ms-linear-gradient(top,  #1b1b1b 0%,#262626 100%); /* IE10+ */
	background: linear-gradient(top,  #1b1b1b 0%,#262626 100%); /* W3C */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1b1b1b', endColorstr='#262626',GradientType=0 ); /* IE6-8 */
	border:1px solid #000;
	border-radius:5px;
	-webkit-border-radius:5px;
	-moz-border-radius:5px;
	-o-border-radius:5px;
	box-shadow:0 1px 0 rgba(255,255,255,0.2), inset 0 2px 0 rgba(0,0,0,0.5);
	-webkit-box-shadow:0 1px 0 rgba(255,255,255,0.2), inset 0 2px 0 rgba(0,0,0,0.5);
	-moz-box-shadow:0 1px 0 rgba(255,255,255,0.2), inset 0 2px 0 rgba(0,0,0,0.5);
	-o-box-shadow:0 1px 0 rgba(255,255,255,0.2), inset 0 2px 0 rgba(0,0,0,0.5);
	font-size: .8em;
	color:#fff;
}

.vmf-search-input:focus{
	outline:none;
}

.vmf-search-submit {
	width: 100px;
	height: 42px;
	cursor: pointer !important;
	background: #353535; /* Old browsers */
	/* IE9 SVG, needs conditional override of 'filter' to 'none' */
	background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSI1MCUiIHN0b3AtY29sb3I9IiMzNTM1MzUiIHN0b3Atb3BhY2l0eT0iMSIvPgogICAgPHN0b3Agb2Zmc2V0PSI1MSUiIHN0b3AtY29sb3I9IiMxYjFiMWIiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
	background: -moz-linear-gradient(top,  #353535 51%, #1b1b1b 52%); /* FF3.6+ */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(51%,#353535), color-stop(52%,#1b1b1b)); /* Chrome,Safari4+ */
	background: -webkit-linear-gradient(top,  #353535 51%,#1b1b1b 52%); /* Chrome10+,Safari5.1+ */
	background: -o-linear-gradient(top,  #353535 51%,#1b1b1b 52%); /* Opera 11.10+ */
	background: -ms-linear-gradient(top,  #353535 51%,#1b1b1b 52%); /* IE10+ */
	background: linear-gradient(top,  #353535 51%,#1b1b1b 52%); /* W3C */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#353535', endColorstr='#1b1b1b',GradientType=0 ); /* IE6-8 */
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
	-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
	-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
	-o-box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
	border-radius: 4px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	-o-border-radius: 4px;
	border: 1px solid #000 !important;
	color: #fff;
	position: absolute;
	right: 11px;
	top: 8.5px;
	padding: 10px !important;
}

.vmf-search-submit:active{
	background: #1b1b1b; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
	background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzFiMWIxYiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMzNTM1MzUiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
	background: -moz-linear-gradient(top,  #1b1b1b 0%, #353535 100%); /* FF3.6+ */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1b1b1b), color-stop(100%,#353535)); /* Chrome,Safari4+ */
	background: -webkit-linear-gradient(top,  #1b1b1b 0%,#353535 100%); /* Chrome10+,Safari5.1+ */
	background: -o-linear-gradient(top,  #1b1b1b 0%,#353535 100%); /* Opera 11.10+ */
	background: -ms-linear-gradient(top,  #1b1b1b 0%,#353535 100%); /* IE10+ */
	background: linear-gradient(top,  #1b1b1b 0%,#353535 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1b1b1b', endColorstr='#353535',GradientType=0 ); /* IE6-8 */
}

/* clears the search form placeholder text on focus */
.vmf-search-form input[type="search"]:focus::-webkit-input-placeholder { color:transparent; }
.vmf-search-form input[type="search"]:focus:-moz-placeholder { color:transparent; } /* Firefox 18- */
.vmf-search-form input[type="search"]:focus::-moz-placeholder { color:transparent; } /* Firefox 19+ */
.vmf-search-form input[type="search"]:focus:-ms-input-placeholder { color:transparent; } /* oldIE ;) */

Finally, to include the Search Icon as the last item in the menu, add the following to functions.php.

add_filter( 'wp_nav_menu_items', 'add_show_search_button', 10, 2 );
/**
 * @param string   $menu HTML string of list items.
 * @param stdClass $args Menu arguments.
 *
 * @return string Amended HTML string of list items.
 */
function add_show_search_button( $menu, $args ) {
	if ( 'menu genesis-nav-menu' !== $args->menu_class  )
		return $menu;

	$menu  .= '
  • '; return $menu; }

    If you've done every things correctly, you should have a search form styled to look as the one on this site. None of this code however, provides mobile responsiveness to the form. We'll address that in another article.

    • 0shares
    • Facebook0
    • Twitter0
    • Pinterest0
    • LinkedIn0
    • Print
    • SMS0

    Filed Under: Code Snippet, Computers and Internet, How To, Programming, WordPress Tagged With: Code Snippet, Computers and Internet, How To, Programming, WordPress

    About Victor M. Font Jr.

    Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

    Primary Sidebar

    Shopping Cart

    Books

    • Ultimate Guide to the SDLC front cover The Ultimate Guide to the SDLC
      Rated 5.00 out of 5
      $74.95
    • Winning With WordPress Basics 2nd Edition Winning With WordPress Basics 2nd Edition $19.95

    Recent Articles

    • Modern Scam Defense: How Consumers and Businesses Can Recognize and Stop Email, Phone, and Text Fraud
    • How to Write a PRD So Dense It’s Technically a Novel
    • Top 5 Plugin Names That Scare Our Legal Department
    • When Agile Meets Our 3-Year Waterfall Roadmap: A Love Story
    • Why Our Enterprise Needs 27 Stakeholders to Approve a Button Color Change

    Top 10 Article Categories

    Best Practice Code Snippet Computers and Internet Genesis How To Leadership Programming Servant Leadership Tutorial WordPress

     
    We only use analytical cookies on our website that allow us to recognize and count the number of visitors, but they do not identify you individually. They help us to improve the way our website works. By clicking Accept you, agree to cookies being used in accordance with our Cookie Policy.