Input box takes full scr onclick or onchange
up vote
0
down vote
favorite
Hey I building a react app and I have a navigation bar which looks like this
import React, { Component} from 'react';
import NavImage from "../images/kickstarter.png";
import './navbar.css';
class Navbar extends Component {
render () {
return (
<nav className="navbar navbar-expand-lg navbar-light">
<div className="container">
<ul className="navbar-nav mr-auto">
<img src={NavImage} width="170" height="60" className="" alt="Kickstarter"/>
</ul>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
</ul>
<form className="form-inline my-2 my-lg-0">
<input className="form-control mr-sm-2 cus-nav-input" type="search" placeholder="Search Project" aria-label="Search" />
</form>
</div>
</div>
</nav>
)
}
}
export default Navbar;
This looks something like this
Now, when user clicks on a search bar, I want it to occupy complete navbar, something similar to what product hunt have done
Question: Any idea how can I achieve it?
javascript reactjs
add a comment |
up vote
0
down vote
favorite
Hey I building a react app and I have a navigation bar which looks like this
import React, { Component} from 'react';
import NavImage from "../images/kickstarter.png";
import './navbar.css';
class Navbar extends Component {
render () {
return (
<nav className="navbar navbar-expand-lg navbar-light">
<div className="container">
<ul className="navbar-nav mr-auto">
<img src={NavImage} width="170" height="60" className="" alt="Kickstarter"/>
</ul>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
</ul>
<form className="form-inline my-2 my-lg-0">
<input className="form-control mr-sm-2 cus-nav-input" type="search" placeholder="Search Project" aria-label="Search" />
</form>
</div>
</div>
</nav>
)
}
}
export default Navbar;
This looks something like this
Now, when user clicks on a search bar, I want it to occupy complete navbar, something similar to what product hunt have done
Question: Any idea how can I achieve it?
javascript reactjs
onFocusIn event on input type text you can add a class to input element or its parent element to make it look like you want and onFocusOut you can remove the class
– Mohit Tilwani
Nov 11 at 13:36
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Hey I building a react app and I have a navigation bar which looks like this
import React, { Component} from 'react';
import NavImage from "../images/kickstarter.png";
import './navbar.css';
class Navbar extends Component {
render () {
return (
<nav className="navbar navbar-expand-lg navbar-light">
<div className="container">
<ul className="navbar-nav mr-auto">
<img src={NavImage} width="170" height="60" className="" alt="Kickstarter"/>
</ul>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
</ul>
<form className="form-inline my-2 my-lg-0">
<input className="form-control mr-sm-2 cus-nav-input" type="search" placeholder="Search Project" aria-label="Search" />
</form>
</div>
</div>
</nav>
)
}
}
export default Navbar;
This looks something like this
Now, when user clicks on a search bar, I want it to occupy complete navbar, something similar to what product hunt have done
Question: Any idea how can I achieve it?
javascript reactjs
Hey I building a react app and I have a navigation bar which looks like this
import React, { Component} from 'react';
import NavImage from "../images/kickstarter.png";
import './navbar.css';
class Navbar extends Component {
render () {
return (
<nav className="navbar navbar-expand-lg navbar-light">
<div className="container">
<ul className="navbar-nav mr-auto">
<img src={NavImage} width="170" height="60" className="" alt="Kickstarter"/>
</ul>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
</ul>
<form className="form-inline my-2 my-lg-0">
<input className="form-control mr-sm-2 cus-nav-input" type="search" placeholder="Search Project" aria-label="Search" />
</form>
</div>
</div>
</nav>
)
}
}
export default Navbar;
This looks something like this
Now, when user clicks on a search bar, I want it to occupy complete navbar, something similar to what product hunt have done
Question: Any idea how can I achieve it?
javascript reactjs
javascript reactjs
asked Nov 11 at 13:19
KuchBhi
707220
707220
onFocusIn event on input type text you can add a class to input element or its parent element to make it look like you want and onFocusOut you can remove the class
– Mohit Tilwani
Nov 11 at 13:36
add a comment |
onFocusIn event on input type text you can add a class to input element or its parent element to make it look like you want and onFocusOut you can remove the class
– Mohit Tilwani
Nov 11 at 13:36
onFocusIn event on input type text you can add a class to input element or its parent element to make it look like you want and onFocusOut you can remove the class
– Mohit Tilwani
Nov 11 at 13:36
onFocusIn event on input type text you can add a class to input element or its parent element to make it look like you want and onFocusOut you can remove the class
– Mohit Tilwani
Nov 11 at 13:36
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You could use a onclick function that sets the z-level of the search bar to 1 and sets the width to be equal to or a little smaller than the main nav-bar.
It’d look something like this
In the navbar input add:
onclick=“expandSearchBar()”
Then somewhere add the function:
function expandSearchBar() {
//get the id of the search bar and set css to what you need
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You could use a onclick function that sets the z-level of the search bar to 1 and sets the width to be equal to or a little smaller than the main nav-bar.
It’d look something like this
In the navbar input add:
onclick=“expandSearchBar()”
Then somewhere add the function:
function expandSearchBar() {
//get the id of the search bar and set css to what you need
}
add a comment |
up vote
0
down vote
You could use a onclick function that sets the z-level of the search bar to 1 and sets the width to be equal to or a little smaller than the main nav-bar.
It’d look something like this
In the navbar input add:
onclick=“expandSearchBar()”
Then somewhere add the function:
function expandSearchBar() {
//get the id of the search bar and set css to what you need
}
add a comment |
up vote
0
down vote
up vote
0
down vote
You could use a onclick function that sets the z-level of the search bar to 1 and sets the width to be equal to or a little smaller than the main nav-bar.
It’d look something like this
In the navbar input add:
onclick=“expandSearchBar()”
Then somewhere add the function:
function expandSearchBar() {
//get the id of the search bar and set css to what you need
}
You could use a onclick function that sets the z-level of the search bar to 1 and sets the width to be equal to or a little smaller than the main nav-bar.
It’d look something like this
In the navbar input add:
onclick=“expandSearchBar()”
Then somewhere add the function:
function expandSearchBar() {
//get the id of the search bar and set css to what you need
}
answered Nov 11 at 13:36
thecoolwinter
85
85
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fstackoverflow.com%2fquestions%2f53249135%2finput-box-takes-full-scr-onclick-or-onchange%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
onFocusIn event on input type text you can add a class to input element or its parent element to make it look like you want and onFocusOut you can remove the class
– Mohit Tilwani
Nov 11 at 13:36