I need help with this code. How can I get the search field to display when clicking on the search-icon.svg?
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<label>
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span>
<input type="search" class="search-field"
placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder' ) ?>"
value="<?php echo get_search_query() ?>" name="s"
title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
</label>
<input type="image" alt="Search" src="<?php bloginfo( 'template_url' ); ?>/images/search-icon.svg" />
.site-header .search-field {
background-color: transparent;
border: none;
cursor: pointer;
height: 37px;
padding: 0 0 10px 34px;
position: relative;
-webkit-transition: width 400ms ease, background 400ms ease;
transition: width 400ms ease, background 400ms ease;
width: 0;
}
.site-header .search-field:focus {
background-color: #fff;
border: 2px solid #333;
cursor: text;
outline: 0;
width: 230px;
}
.search-form
.search-submit {
display:none;
}
input[type="image"] {
height: 30px;
}
input[type="image"]
is for having a submit button that's an image. If you want the image to be a toggle you should output it as a regular image, or inside a<button>
element and toggle it with JavaScript. Not really anything to do with WordPress.