Skip to content

Instantly share code, notes, and snippets.

@CHINOBv
Last active November 25, 2020 09:34
Show Gist options
  • Save CHINOBv/174326a3ccfe486aae24f8d45607c0c6 to your computer and use it in GitHub Desktop.
Save CHINOBv/174326a3ccfe486aae24f8d45607c0c6 to your computer and use it in GitHub Desktop.
Agregar las clases y solo alternar la clase show en la clase nav con el evento click en x elemento, los colores se cambian desde la variable
.nav {
display: flex;
font-size: 18px;
width: 100%;
height: 75px;
justify-content: space-between;
align-items: center;
&-title {
color: #fff;
font-size: 35px;
padding: 0 80;
font-weight: bold;
}
&-list {
display: flex;
list-style: none;
margin-right: 30px;
z-index: 10;
}
&-list li {
border-radius: 3px;
margin: 0 5px;
}
&-list li:hover,
li:active {
//background-color: rgba(0, 0, 0, .3);
text-shadow: 2px 2px 5px #999;
transition: 0.4s;
}
&-list-item {
display: block;
padding: 7px 13px;
text-decoration: none;
font-size: 18px;
color: #fff;
text-transform: uppercase;
}
}
#btn-nav {
margin-right: 30px;
font-size: 25px;
color: #fff;
cursor: pointer;
display: none;
}
ul.show {
top: 65px;
}
@media screen and (max-width: 952px) {
.nav-title {
font-size: 30px;
padding-left: 35px;
}
.nav-list-item {
font-size: 16px;
}
}
@media screen and (max-width: 858px) {
.nav {
height: 65px;
}
#btn-nav {
display: inline-flex;
}
.nav-list {
position: fixed;
flex-direction: column;
width: 100%;
height: calc(100% - 65px);
background-color: $secondary;
top: 100vh;
text-align: center;
transition: all 0.4s;
}
.nav-list li {
margin: 30px 0 0;
line-height: 30px;
& :hover {
background: none;
}
}
.nav-list-item {
font-size: 20px;
font-weight: bold;
}
.nav-title {
font-size: 25px;
padding-left: 35px;
}
}
import { useState } from "react";
const Header = () => {
const [showMenu, setShowMenu] = useState(false);
return (
<div>
<nav className="nav">
<p className="nav-title">PixaHi</p>
<ul className={`nav-list ${showMenu ? "show" : ""}`}>
<li>
<a className="nav-list-item" href="/">
Fotos
</a>
</li>
<li>
<a className="nav-list-item" href="/">
Ilustraciones
</a>
</li>
</ul>
<div id="btn-nav" onClick={() => setShowMenu(!showMenu ? true : false)}>
<i className="fas fa-bars"></i>
</div>
</nav>
</div>
);
};
export default Header;
$primary: #5039E7;
$secondary: #7A58FF;
$tither: #A178FF;
$for: #C798FF;
$success: #5039E7;
*, *:after, *:before{
box-sizing: border-box;
padding: 0;
margin: 0;
outline: none;
box-sizing: border-box;
}
body{
background-color: $primary;
color: #fff;
font-size: 14px;
font-family: 'Roboto', sans-serif;
}
@import './_navbar';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment