How to change a search input box into a search icon as in mobile view
How to have a search icon in the place of search box in the header, once the search icon is clicked the search box has to drop down, can some one help me how to do it
search header magento-2.2.1
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
How to have a search icon in the place of search box in the header, once the search icon is clicked the search box has to drop down, can some one help me how to do it
search header magento-2.2.1
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
How to have a search icon in the place of search box in the header, once the search icon is clicked the search box has to drop down, can some one help me how to do it
search header magento-2.2.1
How to have a search icon in the place of search box in the header, once the search icon is clicked the search box has to drop down, can some one help me how to do it
search header magento-2.2.1
search header magento-2.2.1
asked Dec 4 '17 at 8:19
anirvananirvan
1917
1917
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Example: Default magento search form : only required part shown in example, in phtml only update the attribute of elements
Form Element add extra class = searchbox
Form Input search box add extra class = searchbox-input
& onkeyup=buttonUp()
Form Submit button extra class = searchbox-submit
And Next to submit button add a span element
<span class="searchbox-icon">Find</span>
<form class="form minisearch searchbox" id="search_mini_form" ...>
<div class="field search">
<label class="label" ... >
<span>Search</span>
</label>
<div class="control">
<input id="search" type="text" ... class="input-text searchbox-input" onkeyup="buttonUp();">
</div>
</div>
<div class="actions">
<button type="submit" class="action search searchbox-submit" >
<span>Go</span>
</button>
<span class="searchbox-icon">Find</span>
</div>
</form>
As your required for mobile only so add css in mobile media query that is below 768px
.searchbox{
position:relative;
min-width:50px;
width:0%;
height:50px;
float:right;
overflow:hidden;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
-ms-transition: width 0.3s;
-o-transition: width 0.3s;
transition: width 0.3s;
}
.searchbox-input{
top:0;
right:0;
border:0;
outline:0;
background:#dcddd8;
width:100%;
height:50px;
margin:0;
padding:0px 55px 0px 20px;
font-size:20px;
color:red;
}
.searchbox-input::-webkit-input-placeholder {
color: #d74b4b;
}
.searchbox-input:-moz-placeholder {
color: #d74b4b;
}
.searchbox-input::-moz-placeholder {
color: #d74b4b;
}
.searchbox-input:-ms-input-placeholder {
color: #d74b4b;
}
.searchbox-icon,
.searchbox-submit{
width:50px;
height:50px;
display:block;
position:absolute;
top:0;
font-family:verdana;
font-size:22px;
right:0;
padding:0;
margin:0;
border:0;
outline:0;
line-height:50px;
text-align:center;
cursor:pointer;
color:#dcddd8;
background:#172b3c;
}
.searchbox-open{
width:100%;
}
.label {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
As your required for mobile only so trigger js in mobile below 768px only
$(document).ready(function(){
var submitIcon = $('.searchbox-icon');
var inputBox = $('.searchbox-input');
var searchBox = $('.searchbox');
var isOpen = false;
submitIcon.click(function(){
if(isOpen == false){
searchBox.addClass('searchbox-open');
inputBox.focus();
isOpen = true;
} else {
searchBox.removeClass('searchbox-open');
inputBox.focusout();
isOpen = false;
}
});
submitIcon.mouseup(function(){
return false;
});
searchBox.mouseup(function(){
return false;
});
$(document).mouseup(function(){
if(isOpen == true){
$('.searchbox-icon').css('display','block');
submitIcon.click();
}
});
});
function buttonUp(){
var inputVal = $('.searchbox-input').val();
inputVal = $.trim(inputVal).length;
if( inputVal !== 0){
$('.searchbox-icon').css('display','none');
} else {
$('.searchbox-input').val('');
$('.searchbox-icon').css('display','block');
}
}
Note : It just an example to achieve your output, update css and js per your need.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f204277%2fhow-to-change-a-search-input-box-into-a-search-icon-as-in-mobile-view%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Example: Default magento search form : only required part shown in example, in phtml only update the attribute of elements
Form Element add extra class = searchbox
Form Input search box add extra class = searchbox-input
& onkeyup=buttonUp()
Form Submit button extra class = searchbox-submit
And Next to submit button add a span element
<span class="searchbox-icon">Find</span>
<form class="form minisearch searchbox" id="search_mini_form" ...>
<div class="field search">
<label class="label" ... >
<span>Search</span>
</label>
<div class="control">
<input id="search" type="text" ... class="input-text searchbox-input" onkeyup="buttonUp();">
</div>
</div>
<div class="actions">
<button type="submit" class="action search searchbox-submit" >
<span>Go</span>
</button>
<span class="searchbox-icon">Find</span>
</div>
</form>
As your required for mobile only so add css in mobile media query that is below 768px
.searchbox{
position:relative;
min-width:50px;
width:0%;
height:50px;
float:right;
overflow:hidden;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
-ms-transition: width 0.3s;
-o-transition: width 0.3s;
transition: width 0.3s;
}
.searchbox-input{
top:0;
right:0;
border:0;
outline:0;
background:#dcddd8;
width:100%;
height:50px;
margin:0;
padding:0px 55px 0px 20px;
font-size:20px;
color:red;
}
.searchbox-input::-webkit-input-placeholder {
color: #d74b4b;
}
.searchbox-input:-moz-placeholder {
color: #d74b4b;
}
.searchbox-input::-moz-placeholder {
color: #d74b4b;
}
.searchbox-input:-ms-input-placeholder {
color: #d74b4b;
}
.searchbox-icon,
.searchbox-submit{
width:50px;
height:50px;
display:block;
position:absolute;
top:0;
font-family:verdana;
font-size:22px;
right:0;
padding:0;
margin:0;
border:0;
outline:0;
line-height:50px;
text-align:center;
cursor:pointer;
color:#dcddd8;
background:#172b3c;
}
.searchbox-open{
width:100%;
}
.label {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
As your required for mobile only so trigger js in mobile below 768px only
$(document).ready(function(){
var submitIcon = $('.searchbox-icon');
var inputBox = $('.searchbox-input');
var searchBox = $('.searchbox');
var isOpen = false;
submitIcon.click(function(){
if(isOpen == false){
searchBox.addClass('searchbox-open');
inputBox.focus();
isOpen = true;
} else {
searchBox.removeClass('searchbox-open');
inputBox.focusout();
isOpen = false;
}
});
submitIcon.mouseup(function(){
return false;
});
searchBox.mouseup(function(){
return false;
});
$(document).mouseup(function(){
if(isOpen == true){
$('.searchbox-icon').css('display','block');
submitIcon.click();
}
});
});
function buttonUp(){
var inputVal = $('.searchbox-input').val();
inputVal = $.trim(inputVal).length;
if( inputVal !== 0){
$('.searchbox-icon').css('display','none');
} else {
$('.searchbox-input').val('');
$('.searchbox-icon').css('display','block');
}
}
Note : It just an example to achieve your output, update css and js per your need.
add a comment |
Example: Default magento search form : only required part shown in example, in phtml only update the attribute of elements
Form Element add extra class = searchbox
Form Input search box add extra class = searchbox-input
& onkeyup=buttonUp()
Form Submit button extra class = searchbox-submit
And Next to submit button add a span element
<span class="searchbox-icon">Find</span>
<form class="form minisearch searchbox" id="search_mini_form" ...>
<div class="field search">
<label class="label" ... >
<span>Search</span>
</label>
<div class="control">
<input id="search" type="text" ... class="input-text searchbox-input" onkeyup="buttonUp();">
</div>
</div>
<div class="actions">
<button type="submit" class="action search searchbox-submit" >
<span>Go</span>
</button>
<span class="searchbox-icon">Find</span>
</div>
</form>
As your required for mobile only so add css in mobile media query that is below 768px
.searchbox{
position:relative;
min-width:50px;
width:0%;
height:50px;
float:right;
overflow:hidden;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
-ms-transition: width 0.3s;
-o-transition: width 0.3s;
transition: width 0.3s;
}
.searchbox-input{
top:0;
right:0;
border:0;
outline:0;
background:#dcddd8;
width:100%;
height:50px;
margin:0;
padding:0px 55px 0px 20px;
font-size:20px;
color:red;
}
.searchbox-input::-webkit-input-placeholder {
color: #d74b4b;
}
.searchbox-input:-moz-placeholder {
color: #d74b4b;
}
.searchbox-input::-moz-placeholder {
color: #d74b4b;
}
.searchbox-input:-ms-input-placeholder {
color: #d74b4b;
}
.searchbox-icon,
.searchbox-submit{
width:50px;
height:50px;
display:block;
position:absolute;
top:0;
font-family:verdana;
font-size:22px;
right:0;
padding:0;
margin:0;
border:0;
outline:0;
line-height:50px;
text-align:center;
cursor:pointer;
color:#dcddd8;
background:#172b3c;
}
.searchbox-open{
width:100%;
}
.label {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
As your required for mobile only so trigger js in mobile below 768px only
$(document).ready(function(){
var submitIcon = $('.searchbox-icon');
var inputBox = $('.searchbox-input');
var searchBox = $('.searchbox');
var isOpen = false;
submitIcon.click(function(){
if(isOpen == false){
searchBox.addClass('searchbox-open');
inputBox.focus();
isOpen = true;
} else {
searchBox.removeClass('searchbox-open');
inputBox.focusout();
isOpen = false;
}
});
submitIcon.mouseup(function(){
return false;
});
searchBox.mouseup(function(){
return false;
});
$(document).mouseup(function(){
if(isOpen == true){
$('.searchbox-icon').css('display','block');
submitIcon.click();
}
});
});
function buttonUp(){
var inputVal = $('.searchbox-input').val();
inputVal = $.trim(inputVal).length;
if( inputVal !== 0){
$('.searchbox-icon').css('display','none');
} else {
$('.searchbox-input').val('');
$('.searchbox-icon').css('display','block');
}
}
Note : It just an example to achieve your output, update css and js per your need.
add a comment |
Example: Default magento search form : only required part shown in example, in phtml only update the attribute of elements
Form Element add extra class = searchbox
Form Input search box add extra class = searchbox-input
& onkeyup=buttonUp()
Form Submit button extra class = searchbox-submit
And Next to submit button add a span element
<span class="searchbox-icon">Find</span>
<form class="form minisearch searchbox" id="search_mini_form" ...>
<div class="field search">
<label class="label" ... >
<span>Search</span>
</label>
<div class="control">
<input id="search" type="text" ... class="input-text searchbox-input" onkeyup="buttonUp();">
</div>
</div>
<div class="actions">
<button type="submit" class="action search searchbox-submit" >
<span>Go</span>
</button>
<span class="searchbox-icon">Find</span>
</div>
</form>
As your required for mobile only so add css in mobile media query that is below 768px
.searchbox{
position:relative;
min-width:50px;
width:0%;
height:50px;
float:right;
overflow:hidden;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
-ms-transition: width 0.3s;
-o-transition: width 0.3s;
transition: width 0.3s;
}
.searchbox-input{
top:0;
right:0;
border:0;
outline:0;
background:#dcddd8;
width:100%;
height:50px;
margin:0;
padding:0px 55px 0px 20px;
font-size:20px;
color:red;
}
.searchbox-input::-webkit-input-placeholder {
color: #d74b4b;
}
.searchbox-input:-moz-placeholder {
color: #d74b4b;
}
.searchbox-input::-moz-placeholder {
color: #d74b4b;
}
.searchbox-input:-ms-input-placeholder {
color: #d74b4b;
}
.searchbox-icon,
.searchbox-submit{
width:50px;
height:50px;
display:block;
position:absolute;
top:0;
font-family:verdana;
font-size:22px;
right:0;
padding:0;
margin:0;
border:0;
outline:0;
line-height:50px;
text-align:center;
cursor:pointer;
color:#dcddd8;
background:#172b3c;
}
.searchbox-open{
width:100%;
}
.label {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
As your required for mobile only so trigger js in mobile below 768px only
$(document).ready(function(){
var submitIcon = $('.searchbox-icon');
var inputBox = $('.searchbox-input');
var searchBox = $('.searchbox');
var isOpen = false;
submitIcon.click(function(){
if(isOpen == false){
searchBox.addClass('searchbox-open');
inputBox.focus();
isOpen = true;
} else {
searchBox.removeClass('searchbox-open');
inputBox.focusout();
isOpen = false;
}
});
submitIcon.mouseup(function(){
return false;
});
searchBox.mouseup(function(){
return false;
});
$(document).mouseup(function(){
if(isOpen == true){
$('.searchbox-icon').css('display','block');
submitIcon.click();
}
});
});
function buttonUp(){
var inputVal = $('.searchbox-input').val();
inputVal = $.trim(inputVal).length;
if( inputVal !== 0){
$('.searchbox-icon').css('display','none');
} else {
$('.searchbox-input').val('');
$('.searchbox-icon').css('display','block');
}
}
Note : It just an example to achieve your output, update css and js per your need.
Example: Default magento search form : only required part shown in example, in phtml only update the attribute of elements
Form Element add extra class = searchbox
Form Input search box add extra class = searchbox-input
& onkeyup=buttonUp()
Form Submit button extra class = searchbox-submit
And Next to submit button add a span element
<span class="searchbox-icon">Find</span>
<form class="form minisearch searchbox" id="search_mini_form" ...>
<div class="field search">
<label class="label" ... >
<span>Search</span>
</label>
<div class="control">
<input id="search" type="text" ... class="input-text searchbox-input" onkeyup="buttonUp();">
</div>
</div>
<div class="actions">
<button type="submit" class="action search searchbox-submit" >
<span>Go</span>
</button>
<span class="searchbox-icon">Find</span>
</div>
</form>
As your required for mobile only so add css in mobile media query that is below 768px
.searchbox{
position:relative;
min-width:50px;
width:0%;
height:50px;
float:right;
overflow:hidden;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
-ms-transition: width 0.3s;
-o-transition: width 0.3s;
transition: width 0.3s;
}
.searchbox-input{
top:0;
right:0;
border:0;
outline:0;
background:#dcddd8;
width:100%;
height:50px;
margin:0;
padding:0px 55px 0px 20px;
font-size:20px;
color:red;
}
.searchbox-input::-webkit-input-placeholder {
color: #d74b4b;
}
.searchbox-input:-moz-placeholder {
color: #d74b4b;
}
.searchbox-input::-moz-placeholder {
color: #d74b4b;
}
.searchbox-input:-ms-input-placeholder {
color: #d74b4b;
}
.searchbox-icon,
.searchbox-submit{
width:50px;
height:50px;
display:block;
position:absolute;
top:0;
font-family:verdana;
font-size:22px;
right:0;
padding:0;
margin:0;
border:0;
outline:0;
line-height:50px;
text-align:center;
cursor:pointer;
color:#dcddd8;
background:#172b3c;
}
.searchbox-open{
width:100%;
}
.label {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
As your required for mobile only so trigger js in mobile below 768px only
$(document).ready(function(){
var submitIcon = $('.searchbox-icon');
var inputBox = $('.searchbox-input');
var searchBox = $('.searchbox');
var isOpen = false;
submitIcon.click(function(){
if(isOpen == false){
searchBox.addClass('searchbox-open');
inputBox.focus();
isOpen = true;
} else {
searchBox.removeClass('searchbox-open');
inputBox.focusout();
isOpen = false;
}
});
submitIcon.mouseup(function(){
return false;
});
searchBox.mouseup(function(){
return false;
});
$(document).mouseup(function(){
if(isOpen == true){
$('.searchbox-icon').css('display','block');
submitIcon.click();
}
});
});
function buttonUp(){
var inputVal = $('.searchbox-input').val();
inputVal = $.trim(inputVal).length;
if( inputVal !== 0){
$('.searchbox-icon').css('display','none');
} else {
$('.searchbox-input').val('');
$('.searchbox-icon').css('display','block');
}
}
Note : It just an example to achieve your output, update css and js per your need.
answered Mar 31 '18 at 23:06
Kanhaiya lalKanhaiya lal
880317
880317
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f204277%2fhow-to-change-a-search-input-box-into-a-search-icon-as-in-mobile-view%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown