I am trying to recreate this design:
Click to view
However, the below is currently occurring.
Click to view
I am trying to push the SignUp and Login buttons to the bottom of the sidebar to match the first image. Am I missing a CSS class that would allow me to do so, or would this be a JS configuration? Hope I have not overlooked something basic that would allow me to achieve this state.
Sidebar.js
import React from "react";
import "../App.css";
import { SidebarData } from './SidebarData'
import Logo from './Logo.svg'
import { Login } from './Login'
import { SignUp } from './SignUp'
function Sidebar() {
return (
<div className="Sidebar">
<div className="Header">
<div><img src = {Logo} alt='Logo’ className='Logo’ /></div>
</div>
<div class="line-break" />
<ul className="SidebarList">
{SidebarData.map((val, key) => {
return (
<li
key={key}
className="row"
id={window.location.pathname == val.link ? "active" : ""}
onClick={() => {
window.location.pathname = val.link;
}}
>
<div id="icon">{val.icon}</div> <div id="title">{val.title}</div>
</li>
);
})}
</ul>
<div class="line-break" />
<div className="footer">
<ul className= "SidebarList">
{Login.map((val, key) => {
return (
<li
key={key}
className="Login"
id={window.location.pathname == val.link ? "active" : ""}
onClick={() => {
window.location.pathname = val.link;
}}
>
<div id="title">{val.title}</div>
</li>
)}
)}
</ul>
<ul className= "SidebarList">
{SignUp.map((val, key) => {
return (
<li
key={key}
className="SignUp"
id={window.location.pathname == val.link ? "active" : ""}
onClick={() => {
window.location.pathname = val.link;
}}
>
<div id="title">{val.title}</div>
</li>
)}
)}
</ul>
</div>
</div>
Here is CSS
.App {
width: 100vw;
height: 100vh;
}
body {
margin: 0;
padding: 0;
}
.Sidebar {
height: 100%;
width: 300px;
background-color: white;
border-right: 1px solid #F0F4FB;
padding-left: 15px;
box-sizing: border-box;
}
.SidebarList {
height: auto;
width: 100%;
padding-left: 15px;
font-size: 18px;
border: 2px #FD954E;
box-sizing: border-box
}
.SidebarList .row {
width: 100%;
height: 50px;
background-color: white;
list-style-type: none;
margin: 0%;
padding-bottom: 15px;
display: flex;
color: #A7ACB6;
justify-content: center;
align-items: center;
font-family: Arial, Helvetica, sans-serif;
}
.SidebarList .row:hover {
cursor: pointer;
background-color: #E7E7E7 ;
}
.SidebarList #active {
background-color: white;
color: #FD954E
}
.SidebarList .Login {
background-color: white;
color: #FD954E;
width: 90%;
height: 5vh;
right: 1596px;
top: 958px;
border: 1px solid #FD954E;
box-sizing: border-box;
border-radius: 19.5px;
text-align: center;
font-family: Arial, Helvetica, sans-serif
}
.SidebarList .SignUp {
width: 90%;
height: 5vh;
right: 1596px;
top: 1011px;
background: #FD954E;
border-radius: 19.5px;
border: none;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
.row #icon {
flex: 30%;
display: grid;
place-items: center;
transform: scale(1.2)
}
.row #title {
flex: 70%;
}
.Logo {
padding-left: 25px;
padding-top: 25px;
padding-bottom: 30px;
width: 55%;
}
.line-break {
height: 1px;
width: 100%;
background-color: #F0F4FB;
}
ul.nav {
list-style-type: none;
padding: 20px 0 0 40px;
list-style-type: none;
}
ul.nav li {
margin-bottom: 14px;
list-style-type: none;
}
ul.nav li:last-child {
margin-bottom: 0;
list-style-type: none;
}
.footer {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 0;
}
.footer button {
padding: 6px 0;
width: 80%;
margin-bottom: 14px;
}
.footer button:last-child {
margin-bottom: 0;
}
.header .Logo {
height: 40px;
width: 200px;
background-color: grey;
margin: 20px;
}
Without seeing the source for the entire page and not just a couple of the buttons, it is impossible to say for sure, but my guess would be the following is causing your problem:
.Sidebar {
height: 100%;
...
}
Setting height: 100% will only tell the sidebar to take up 100% of the space it needs for its content (or 100% of the height of its bounding container, depending on the display properties of both). I would recommend changing it to this to solve your problem:
.Sidebar {
min-height: 100vh;
...
}
Related
Please help me I am new at web development, how do I change the font awesome icon color?
In my Navbar.js
import { Component } from "react";
import "../Css/Elements/Navbar.css";
class Navbar extends Component {
state = { clicked: false };
handleClick = () => {
this.setState({ clicked: !this.state.clicked });
};
render() {
return (
<>
<nav>
<a id="navlogo" href="/">Blank</a>
<div>
<ul
id="navbar"
className={this.state.clicked ? "#navbar active" : "#navbar"}
>
<li>
<a href="/">
Home
</a>
</li>
<li>
Shop
</li>
<li>
Blog
</li>
<li>
About
</li>
<li>
Contact
</li>
</ul>
</div>
<div id="mobile" onClick={this.handleClick}>
<i
id="bar"
className={this.state.clicked ? "fas fa-times" : "fas fa-bars"}
></i>
</div>
</nav>
</>
);
}
}
export default Navbar;
Css (i put this here just in case)
/* Nav */
nav {
font-family: sans-serif;
display: flex;
position: fixed;
align-items: center;
justify-content: space-between;
background: #F1F5F9;
width: 100%;
padding: 20px 23px;
z-index: 100;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.06);
}
a {
text-decoration: none;
}
#navlogo {
font-weight: 700;
font-size: 25px;
color: #1D3053;
text-transform: uppercase;
transition: all 0.2s ease;
}
#navlogo:hover {
color: #319afc;
}
#navbar {
display: flex;
align-items: center;
justify-content: center;
}
#navbar li {
list-style: none;
padding: 0 20px;
position: relative;
}
#navbar li a {
text-decoration: none;
font-size: 15px;
font-weight: 700 !important;
color: #1D3053;
text-transform: uppercase;
transition: 0.2s ease-in-out;
}
#navbar li a:hover {
color: #319afc;
}
#navbar li a:hover::after {
content: "";
width: 30%;
height: 2px;
background: #319afc;
position: absolute;
bottom: -4px;
left: 20px;
}
#mobile {
display: none;
}
#mobile i {
color: #ffff;
align-items: center;
}
#media screen and (max-width: 769px) {
#navbar {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
position: fixed;
top: 69px;
right: -100%;
width: 270px;
height: 100%;
background: #ffff;
box-shadow: 0 40px 60px rgba(0, 0, 0, 0.1);
padding: 40px 0 0 10px;
z-index: 100;
transition: 0.3s ease-in-out;
}
#navbar.active {
right: 0px;
}
#navbar li {
margin-bottom: 25px;
z-index: 100;
}
#mobile {
display: block;
}
#mobile i {
font-size: 24px;
cursor: pointer;
}
}
how do I change the "fa-bars" and the "fa-times" icon color my website theme is white and the icon is white too, so its hard to see the icon
Sorry for the bad English :)
You can add style={{color: "<color-name>"}} like this:
<i id="bar"
className={this.state.clicked ? "fas fa-times" : "fas fa-bars"}
style={{color: "red"}}>
</i>
The color of icon is controlled either by itself.
#mobile i {
color: red;
align-items: center;
}
I believe fontawesome also allow you to define color from its parent, because by default it also has this line built-in depending on the UI library you are using.
i {
color: inherit;
}
I have set up the logic for Hamburger menu in Navbar.jsx but when I press the hamburger button it just transitions to X button and doesn't display links menu. How do I display the menu and what would be your approach to animating the transition between hamburger and X icon. Here is my code:
import React from 'react'
import './Navbar.css'
import { useState } from 'react'
import { FaSearch } from 'react-icons/fa'
import { NavLink } from 'react-router-dom'
import { GiHamburgerMenu } from 'react-icons/gi'
import { AiOutlineClose } from 'react-icons/ai'
function Navbar() {
const [toggleMenu, setToggleMenu] = useState(false)
const [toggleSearch, setSearchWindow] = useState(false)
return (
<div className='mka__navbar'>
<div className='mka__navbar-links'>
<div className='mka__navbar-links_container'>
<p><NavLink to='/'>HOME</NavLink></p>
<p><NavLink to='/fahrzeugangebote'>FAHRZEUGANGEBOTE</NavLink></p>
<p><NavLink to='/finanzierung'>FINANZIERUNG</NavLink></p>
<p><NavLink to='/fahrzeugankauf'>FAHRZEUGANKAUF</NavLink></p>
<p><NavLink to='/galerie'>GALERIE</NavLink></p>
<p><NavLink to='/kontakt'>KONTAKT</NavLink></p>
<div className='mka__search_column'>
<p><i><FaSearch onClick={() => setSearchWindow(!toggleSearch)} /></i></p>
{
toggleSearch ?
<div className='mka__search-div'>
< input type="text" value="Suche..."/>
</div>
: null
}
</div>
</div>
{
toggleMenu
? <AiOutlineClose color="#fff" className='mka___hamburger-menu' size={27} onClick={() => setToggleMenu(false)} />
: <GiHamburgerMenu size={27} className='mka___hamburger-menu' color="#fff" onClick={() => setToggleMenu(true)} />
}
{
<div className='mka__navbar-menu-margins'>
<div className='mka__navbar-menu_container'>
<div className='mka__navbar-menu_container-links'>
<p><NavLink to='/'>HOME</NavLink></p>
<p><NavLink to='/fahrzeugangebote'>FAHRZEUGANGEBOTE</NavLink></p>
<p><NavLink to='/finanzierung'>FINANZIERUNG</NavLink></p>
<p><NavLink to='/fahrzeugankauf'>FAHRZEUGANKAUF</NavLink></p>
<p><NavLink to='/galerie'>GALERIE</NavLink></p>
<p><NavLink to='/kontakt'>KONTAKT</NavLink></p>
</div>
</div>
</div> && toggleMenu
}
</div>
</div>
);
}
export default Navbar;
And here is my CSS code for the same component:
/* Navbar links */
.mka__navbar {
display: flex;
padding: 2rem;
}
.mka__navbar-links {
flex: 1;
display: flex;
justify-content: end;
align-items: center;
}
.mka__navbar-links_container {
display: flex;
flex-direction: row;
}
.mka__navbar-links_container p {
color: #fff;
font-size: 14px;
line-height: 66px;
text-transform: uppercase;
font-weight: 400;
font-family: var(--font-family);
transition: padding .25s linear;
padding: 0 0.5rem;
cursor: pointer;
}
.mka__navbar-links_container p > a:link {
color: #fff;
}
.mka__navbar-links_container p > a:hover {
transition: 0.5s;
color: #db2d2e;
}
.mka__navbar-links_container p > i:hover {
transition: 0.5s;
color: #db2d2e;
}
.mka__navbar-links_container p > a.active {
color: #db2d2e;
}
/* Hamburger menu */
.mka__navbar-menu_container-links {
color: #fff;
font-size: 14px;
line-height: 66px;
text-transform: uppercase;
font-weight: 400;
font-family: var(--font-family);
padding: 0 1.5rem;
cursor: pointer;
width: 100%;
}
/* Search */
.mka__search-div {
background: #0e0e0ed1;
display: block;
padding: 15px;
width: 327px;
z-index: 888;
border-radius: 0;
border-top: 5px solid #db2d2e;
position: absolute;
margin-left: auto;
margin-right: auto;
left: 26rem;
right: 0;
top: 9rem;
}
input {
border: 1px solid #fff;
background: #0f1215;
color: gray;
padding: 12px;
width: 290px;
}
.mka__search_column {
display: flex;
flex-direction: column;
}
/* Media Queries */
#media (min-width: 992px){
.mka__navbar-links {
justify-content: center;
}
.mka__navbar-menu_container-links {
display: none;
}
.mka___hamburger-menu {
display: none;
}
}
#media (max-width: 992px){
.mka__navbar-links_container {
display: none;
}
.mka__navbar-menu_container {
background-color: #0f1215;
width: 100%;
margin-top: 0.5rem;
border-radius: 5px;
}
.mka__navbar-menu-margins {
margin-left: auto;
margin-right: auto;
padding-left: 15px;
padding-right: 15px;
width: 100%;
margin-top: 40px;
}
}
#media (min-width: 1200px){
.mka__navbar-links_container p {
padding: 0 1rem;
}
}
#media (max-width: 1200px){
.mka__search-div {
left: 21rem;
}
}
I created a hamburger menu which you can toggle it with X icon. and also implemented the drawer transition. the link is here https://codesandbox.io/s/great-hugle-oy5s8b?file=/src/App.js
hope it can help you.
I have a next button in the sliding animation here. I want users to move to the next slide on clicking the next button and it ends on the last slide.
I'm quite new to programming so i tried the below approach to move to a specific div id but not working
<a href={"#slide-${i+2}"}
I'm doing this in react, but for simplicity, i have written this in simple form. Could someone help me with this.
* {
box-sizing: border-box;
}
.slider {
width: 800px;
text-align: center;
overflow: hidden;
}
.slides {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;
/*
scroll-snap-points-x: repeat(300px);
scroll-snap-type: mandatory;
*/
}
.slides::-webkit-scrollbar {
width: 10px;
height: 10px;
}
.slides::-webkit-scrollbar-thumb {
background: black;
border-radius: 10px;
}
.slides::-webkit-scrollbar-track {
background: transparent;
}
.slides > div {
scroll-snap-align: start;
flex-shrink: 0;
width: 800px;
height: 300px;
margin-right: 50px;
border-radius: 10px;
background: #eee;
transform-origin: center center;
transform: scale(1);
transition: transform 0.5s;
position: relative;
display: flex;
justify-content: center;
align-items: center;
font-size: 100px;
}
.slides > div:target {
/* transform: scale(0.8); */
}
img {
object-fit: cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.slider > a {
display: inline-flex;
width: 1.5rem;
height: 1.5rem;
background: white;
text-decoration: none;
align-items: center;
justify-content: center;
border-radius: 50%;
margin: 0 0 0.5rem 0;
position: relative;
}
.slider > a:active {
top: 1px;
}
.slider > a:focus {
background: #000;
}
/* Don't need button navigation */
#supports (scroll-snap-type) {
.slider > a {
display: none;
}
}
html, body {
height: 100%;
overflow: hidden;
}
body {
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(to bottom, #74ABE2, #5563DE);
font-family: 'Ropa Sans', sans-serif;
}
<div class="slider">
<button>Next</button>
<div class="slides">
<div id="slide-1">
1
</div>
<div id="slide-2">
2
</div>
<div id="slide-3">
3
</div>
<div id="slide-4">
4
</div>
<div id="slide-5">
5
</div>
</div>
</div>
You can use scrollIntoView by targeting the id of whatever the next slide is and have a simple state to keep track of the current id.
const App = () => {
const [current, setCurrent] = React.useState(1)
React.useEffect(() => {
if (current === 6) setCurrent(1)
document.querySelector(`#slide-${current > 5?1:current}`).scrollIntoView();
}, [current])
return (
<div className="slider">
<button onClick={() => {
setCurrent(cur=>cur+1)
}}>Next</button>
<div className="slides">
<div id="slide-1">
1
</div>
<div id="slide-2">
2
</div>
<div id="slide-3">
3
</div>
<div id="slide-4">
4
</div>
<div id="slide-5">
5
</div>
</div>
</div>
)
}
ReactDOM.render(<div><App /></div>, document.getElementById("app"));
* {
box-sizing: border-box;
}
.slider {
width: 800px;
text-align: center;
overflow: hidden;
}
.slides {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;
/*
scroll-snap-points-x: repeat(300px);
scroll-snap-type: mandatory;
*/
}
.slides::-webkit-scrollbar {
width: 10px;
height: 10px;
}
.slides::-webkit-scrollbar-thumb {
background: black;
border-radius: 10px;
}
.slides::-webkit-scrollbar-track {
background: transparent;
}
.slides > div {
scroll-snap-align: start;
flex-shrink: 0;
width: 800px;
height: 300px;
margin-right: 50px;
border-radius: 10px;
background: #eee;
transform-origin: center center;
transform: scale(1);
transition: transform 0.5s;
position: relative;
display: flex;
justify-content: center;
align-items: center;
font-size: 100px;
}
.slides > div:target {
/* transform: scale(0.8); */
}
img {
object-fit: cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.slider > a {
display: inline-flex;
width: 1.5rem;
height: 1.5rem;
background: white;
text-decoration: none;
align-items: center;
justify-content: center;
border-radius: 50%;
margin: 0 0 0.5rem 0;
position: relative;
}
.slider > a:active {
top: 1px;
}
.slider > a:focus {
background: #000;
}
/* Don't need button navigation */
#supports (scroll-snap-type) {
.slider > a {
display: none;
}
}
html, body {
height: 100%;
overflow: hidden;
}
body {
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(to bottom, #74ABE2, #5563DE);
font-family: 'Ropa Sans', sans-serif;
}
<script crossorigin src="https://unpkg.com/react#16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom#16/umd/react-dom.development.js"></script>
<div id="app"></div>
Relatively new to React, and am wanting to recreate the design below
enter image description here
I have the base formatting down, but as you will notice, there are lines separating the logo blocks, from the login and signup blocks, with the signup and login buttons pushed to the bottom.
Below is my current code
CSS:
width: 100vw;
height: 100vh;
}
body {
margin: 0;
padding: 0;
}
.Sidebar {
height: 100%;
width: 20%;
background-color: white;
border-right: 1px solid #F0F4FB;
padding-left: 15px;
box-sizing: border-box;
}
.SidebarList {
height: auto;
width: 100%;
padding-left: 15px;
font-size: 18px;
border: 2px #FD954E;
box-sizing: border-box
}
.SidebarList .row {
width: 100%;
height: 50px;
background-color: white;
list-style-type: none;
margin: 0%;
padding-bottom: 15px;
display: flex;
color: #A7ACB6;
justify-content: center;
align-items: center;
font-family: Arial, Helvetica, sans-serif;
}
.SidebarList .row:hover {
cursor: pointer;
background-color: #E7E7E7 ;
}
.SidebarList #active {
background-color: white;
color: #FD954E
}
.SidebarList .Login {
background-color: white;
color: #FD954E;
width: 279px;
height: 39px;
right: 1596px;
top: 958px;
border: 1px solid #FD954E;
box-sizing: border-box;
border-radius: 19.5px;
}
.SidebarList .SignUp {
width: 279px;
height: 39px;
right: 1596px;
top: 1011px;
background: #FD954E;
border-radius: 19.5px;
border: none;
}
.row #icon {
flex: 30%;
display: grid;
place-items: center;
transform: scale(1.2)
}
.row #title {
flex: 70%;
}
.Logo {
padding-left: 25px;
padding-top: 25px;
padding-bottom: 30px;
border-bottom: 1px solid #F0F4FB;
width: 55%;
}
Sidebar.js
import React from "react";
import "../App.css";
import { SidebarData } from './SidebarData'
import Logo from './Logo.svg'
function Sidebar() {
return (
<div className="Sidebar">
<div>
<img src = {Logo} alt='Logo’ className=‘Logo’ />
</div>
<ul className="SidebarList">
{SidebarData.map((val, key) => {
return (
<li
key={key}
className="row"
id={window.location.pathname == val.link ? "active" : ""}
onClick={() => {
window.location.pathname = val.link;
}}
>
<div id="icon">{val.icon}</div> <div id="title">{val.title}</div>
</li>
);
})}
</ul>
<div className= "SidebarList">
<button className="Login">
Login
</button>
</div>
<div className= "SidebarList">
<button className="SignUp">
Sign Up
</button>
</div>
</div>
);
}
export default Sidebar;
How should I structure my code in order to acheive my desired result? Ex: with the logo at the top with the seperator, the list of navigation elements, and then the login and signup buttons at the bottom with the seperator?
Currently, my sidebar looks as follows, with the seperator not full width between the logo and navigation elements, and the buttons extending beyond the sidebar.
enter image description here
It would be easier to simplify the problem with just HTML and CSS as that's much easier to troubleshoot. Part of your problem is that you are defining the width of the sidebar as a percentage of the screen width but elements within the sidebar are defined with a width in pixels. When the browser window is too small, your buttons will appear outside the full width of the sidebar. You could either code all your values as percentages or in pixels. Alternatively, you could use a mix and just set a min-width for the sidebar so that you don't end up with elements out of place.
The reason that your line break is not the full width of your sidebar is because you are defining it with the border-bottom property of the logo. Your logo is not 100% the width of the sidebar so your line break will only be the width of the logo. A better solution would be to define a div that is set to width: 100%. This way, you will have more control.
Here is a simplified solution to your sidebar problem using pixels to define the widths.
HTML:
<div class="sidebar">
<div class="header">
<div class="logo">Logo</div>
</div>
<div class="line-break" />
<div class="content">
<ul class="nav">
<li>Home</li>
<li>Blog</li>
</ul>
</div>
<div class="line-break" />
<div class="footer">
<button class="login">Login</button>
<button class="sign-up">Sign up</button>
</div>
</div>
CSS:
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.sidebar {
width: 300px;
height: 100%;
border-right: 1px solid grey;
}
.line-break {
height: 1px;
width: 100%;
background-color: grey;
}
.header .logo {
height: 40px;
width: 200px;
background-color: grey;
margin: 20px;
}
ul.nav {
list-style-type: none;
padding: 20px 0 0 40px;
}
ul.nav li {
margin-bottom: 14px;
}
ul.nav li:last-child {
margin-bottom: 0;
}
.footer {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 0;
}
.footer button {
padding: 6px 0;
width: 80%;
margin-bottom: 14px;
}
.footer button:last-child {
margin-bottom: 0;
}
And here is a link to a CodePen
where you can see this in action.
Question:
How can I have the navigation of the mobile menu not affect desktop? When I click on the hamburger button to hide the menu and resize the browser to desktop the navigation disappears. I want to know what I did wrong to better understand my mistake.
GIF Video
Full Code Below:
class Navigation extends React.Component {
constructor(props) {
super(props);
this.state = {
show: false
}
this.toggleShow = this.toggleShow.bind(this)
this.hide = this.hide.bind(this)
}
toggleShow() {
this.setState({
show: !this.state.show
});
}
hide(e) {
if (e && e.relatedTarget) {
e.relatedTarget.click();
}
}
render() {
return (
<Router>
<div className="FlexContainer NavbarContainer">
<div className="mobilecontainer LeftNav">
<h2 className="BrandName LeftNav mobileboxmenu inline FarRight">Kommonplaces</h2>
<div
className="hamburger inlinev"
onClick={this.toggleShow}
onBlur={this.hide}>
<img alt="menubtn" src={hamburger}></img>
</div>
</div>
{
this.state.show &&
(
<ul className="NavBar">
<Dropdown/>
<li className="RightNav"><Link to="/">Host Your Space</Link></li>
<li className="RightNav"><Link to="/">About Us</Link></li>
<li className="RightNav"><Link to="/">Contact Us</Link></li>
<li className="RightNav"><Link to="/">Sign Up</Link></li>
<li className="RightNav"><Link to="/">Login</Link></li>
</ul>
)
}
</div>
</Router>
);
}
}
export default Navigation;
SCSS Code:
.NavbarContainer {
border-bottom: 1px #E7E7E7 solid;
.mobilecontainer {
margin: 2.1em;
.hamburger {
display: inline;
img {
width: 35px;
cursor: pointer;
float: right;
}
}
}
.NavBar {
// display: none;
.RightNav {
text-align: center;
padding: 27px 0;
border-right: none;
border-left: none;
border-bottom: 1px #E7E7E7 solid;
font-size: large;
a {
color: #0E0E0E;
}
}
}
.Dropdown {
float: none;
overflow: hidden;
.Dropdown-Content {
position: relative;
background-color: white;
z-index: 2;
min-width: 217px;
a {
float: none;
display: block;
text-align: center;
border: 1px #E7E7E7 solid;
padding: 15px 22px;
}
}
}
.dropdown-content {
a {
&:hover {
background-color: #ddd
}
}
}
.dropdown {
&:hover {
.dropdown-content {
display: block;
}
}
}
.LeftNav {
flex-grow: 8.2;
font-weight: bold;
font-size: large;
display: flex;
align-items: center;
}
#media (min-width: 55em) {
display: flex;
flex-direction: row;
align-items: center;
top: 0;
left: 0;
z-index: 9999;
width: 100%;
height: 60px;
background-color: #ffffff;
padding: 3em;
.LeftNav {
flex-grow: 0.2;
font-weight: bold;
font-size: large;
}
.mobilecontainer {
margin: 0;
.hamburger {
img {
display: none
}
}
}
.NavBar {
display: flex;
.RightNav {
padding-left: 15px;
padding-right: 15px;
text-align: initial;
border-bottom: none;
font-size: large;
}
.FarRight {
flex-grow: 1;
}
}
.Dropdown {
float: left;
overflow: hidden;
.Dropdown-Content {
position: absolute;
top: 96px;
background-color: white;
z-index: 2;
min-width: 217px;
a {
text-align: left;
padding: 15px 22px;
}
}
}
}
}
This is SCSS code that I'm using for this project.
this.state.show is responsible just for toggle mobile menu.when show ===false react ignore rendering navBar neither in mobile or desktop.you cant use this way for your goal.My suggestion is to consider using react-bootstrap Navbar or reactstrap Navbar
I hope this will help you.