I am developing a layout of a mobile application, which will be developed in IONIC, the client sent us an example of how like he want the menu of the application, as you can see in the link below:
https://dribbble.com/shots/1701001-GIF-Exercise
Could you give me an idea how to get this result, from the diagonal menu, picking up the whole screen of the cell phone and keep the menu itens inside their colors?
I'm trying this, but i'm stuck here..
https://codepen.io/d3rsonbr/pen/bLvxgb
<div class="container">
<div>
<span>item1</span>
</div>
<div>
<span>item2</span>
</div>
<div>
<span>item3</span>
</div>
<div>
<span>item4</span>
</div>
<div>
<span>item5</span>
</div>
</div>
CSS:
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,400italic,300italic);
/* ====================================
Navigation
==================================== */
.overlay-navigation {
position: fixed;
z-index: 99;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: hsla(0, 0%, 100%, 0.2);
/*display: none;
opacity: 0;*/
}
nav,
nav ul {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
nav ul {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
list-style: none;
flex-direction: column;
}
nav ul li {
-webkit-flex-basis: 20%;
-ms-flex-preferred-size: 20%;
flex-basis: 20%;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 100%;
overflow: hidden;
/*opacity: 0;
display: none;*/
/*-webkit-transform: rotate(-28deg);
-webkit-transform-origin: top left;
-moz-transform: rotate(-28deg);
-moz-transform-origin: top left;
-ms-transform: rotate(-28deg);
-ms-transform-origin: top left;
-o-transform: rotate(-28deg);
-o-transform-origin: top left;
transform: rotate(-28deg);
transform-origin: top left;*/
}
nav li a {
position: relative;
top: 20%;
color: #fff;
text-transform: uppercase;
font-weight: 300;
letter-spacing: 4px;
text-decoration: none;
display: block;
text-align: center;
font-size: 40px;
opacity: 1;
}
nav li a:before {
content: '';
width: 70px;
height: 2px;
background-color: #fff;
position: absolute;
top: 50%;
left: 0;
z-index: 100;
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
opacity: 0;
-webkit-transition: all .2s linear;
transition: all .2s linear;
}
nav li a:after {
content: attr(data-content);
font-size: 14px;
-webkit-transition: all .2s linear;
transition: all .2s linear;
opacity: 1;
position: absolute;
z-index: 100;
color: #fff;
display: block;
margin-right: auto;
margin-left: auto;
left: 0;
right: 0;
bottom: -25px;
text-transform: none;
font-family: 'Open sans', sans-serif;
font-weight: 600;
letter-spacing: 0;
}
nav li:nth-of-type(1) {
background-color: #29363B
}
nav li:nth-of-type(2) {
background-color: #EA495F
}
nav li:nth-of-type(3) {
background-color: #F4837D
}
nav li:nth-of-type(4) {
background-color: #FDCEA9
}
nav li:nth-of-type(5) {
background-color: #99B998
}
and this another one:
https://codepen.io/d3rsonbr/pen/XZEYKP
Related
I'm not knowing how to increase the height of vitaminpic, which is under container. I'm still new to development, and I know this seems like an amateur mistake. I tried everything I can but it's not working. I believe it has to do with with the fact that it is under the container. I'm trying to make a website that sells vitamins, still new to it but I'm still trying.
#import url('https://fonts.googleapis.com/css2?family=Syne+Mono&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
.background {
width: 100%;
height: 100vh;
background-color: #e0d1cb;
position: relative;
overflow: hidden;
z-index: 2;
}
.nav {
position: fixed;
top: 0;
width: 100%;
display: flex;
justify-content: space-around;
align-items: center;
min-height: 8vh;
background-color: #e0d1cb;
font-family: 'Syne Mono', monospace;
z-index: 3;
}
.nav-links {
display: flex;
justify-content: space-around;
width: 30%;
font-family: 'Syne Mono', monospace;
}
.nav-links li {
list-style: none;
font-family: 'Syne Mono', monospac
}
.nav-links a {
color: rgb(0, 0, 0);
text-decoration: none;
letter-spacing: 2px;
font-weight: bold;
font-size: 14px;
font-family: 'Syne Mono', monospac
}
.burger {
display: none;
}
.burger div {
width: 25px;
height: 3px;
background-color: rgb(226, 226, 226);
margin: 5px;
transition: all 0.3s ease;
}
#media screen and (max-width: 1024px) {
.nav-links {
width: 60%;
}
}
#media screen and (max-width: 768px) {
body {
overflow-x: hidden;
}
.nav-links {
position: fixed;
right: 0px;
height: 92vh;
top: 8vh;
background-color: #e0d1cb;
display: flex;
flex-direction: column;
align-items: center;
width: 20%;
transform: translateX(100%);
transition: transform 0.5s ease-in;
}
.nav-links li {
opacity: 0;
}
.burger {
display: block;
cursor: pointer;
}
}
.nav-active {
transform: translateX(0%);
}
#keyframes navLinkFade {
from {
opacity: 0;
transform: translateX(50px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
.toggle .line1 {
transform: rotate(-45deg) translate(-5px, 6px);
}
.toggle .line2 {
opacity: 0;
}
.toggle .line3 {
transform: rotate(45deg) translate(-5px, -6px);
}
#import url('https://fonts.googleapis.com/css2?family=Syne+Mono&display=swap');
.logo {
resize: both;
font-family: 'Syne Mono', monospace;
}
.link::after {
content: '';
display: block;
width: 0;
height: 2px;
background: #000000;
transition: width .3s;
}
.link:hover::after {
width: 100%;
transition: width .3s;
}
.header {
width: 100%;
background-color: rgba(0, 0, 0, 0.5)
}
.header ul {
text-align: center;
}
.header ul li {
list-style: none;
display: inline-block;
}
.header ul li a {
display: block;
text-decoration: none;
text-transform: uppercase;
color: white;
font-size: 100%;
letter-spacing: 2px;
font-weight: 600;
padding: 25px;
transition: width .3s;
}
.content {
color: #fbfcfd;
position: absolute;
top: 50%;
left: 8%;
transform: translateY(-50%);
z-index: 2;
}
.heading1 {
font-size: 300%;
margin-bottom: 10px 0 30px;
background: transparent;
position: relative;
animation: text 5s 1;
left: 120%;
}
#keyframes text {
0% {
color: transparent;
margin-bottom: -40px;
}
30% {
letter-spacing: 4px;
margin-bottom: -40px;
}
85% {
letter-spacing: 3px%;
margin-bottom: -40px;
}
}
.welcome {
font-size: 30px;
position: relative;
}
.container {
position: absolute;
height: 80%;
width: 30%;
background: #dfcac1;
top: 50%;
left: 35%;
transform: translate(-43%, -60%);
}
.container img {
size: ;
}
.vitaminpic {
width: 100%;
transform: translate(10%, 80%);
padding: 0 10;
}
<head>
<link rel="stylesheet" href="home.css">
</head>
<header class="site-header"></header>
<div class="background">
<div class="nav">
<h1 class="logo">Realvite</h1>
<ul class="nav-links">
<li>
<a href="#" class="link1">
<div class="link1">Home</div>
</a>
</li>
<li>Shop</li>
<li>Contact</li>
</ul>
<div class="burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</div>
</nav>
<div class="container">
<img src="/images/capsule-1079838_1920.jpg" alt="" class="vitaminpic">
</div>
<p style="font-size: 1px;">قيل قديقال</p>
<div class="content">
<small class="welcome"></small>
<h1 class="heading1"></h1>
</div>
</div>
<script src="script.js"></script>
If I were you I would use Bootstrap columns, because not only are these easily configurable, but importing bootstrap also allows you to use a wide variety of HTML, CSS and Javascript libraries which are widely supported. Here's the link - https://getbootstrap.com
In the meantime though, I would recommend removing this:
.container img {
size: ;
}
and changing your container width to 50% to see if that works, because currently you've set your container to 30% width, whereas your image is larger than that, so it isn't fitting inside the container. If 50% doesn't work then try a few different values to try and get it to fit, but as mentioned I would recommend Bootstrap, then you can use "col-md-4" and set the background for that, would probably be much more convenient for you in the long run! :)
I have a hamburger toggled menu using (short) videos as menu options. The css code was written through sass so I will include both the scss and the corresponding css code.
https://frysling.netlify.app/
All these menu options should have functioning links and a hover effect removing the black #000 overlay with a hover effect, setting the opacity of the overlay div to 0.
However, only the first (1/4) and the last (4/4) menu option have the hover effect and functioning links. The links go nowhere atm but the pointer cursor is showing on those two .footer-content divs.
I've tried rewriting the 2nd and 3rd .footer-content HTML divs to be, content aside, the same code as the functioning first and fourth div. I've also tried splitting up the classes into .footer-content-1 till four, nothing changed.
Here is the html code, i've tried to be descriptive in the comments. Forgive me for posting the entire code, I'm just not sure what detail could cause the problem:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://fonts.googleapis.com/css?family=Lora&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="css/style.css" />
<title>Frysling | De Noorderlijkse Wijngaard</title>
</head>
<body>
<!-- Logo & shopping cart -->
<img src="img/logo.png" alt="" id="logo" />
<a href="#"
><img src="img/shopping-cart.png" alt="" id="shopping-cart"
/></a>
<!-- Hamburger Menu -->
<div class="menu-wrap">
<input type="checkbox" class="toggler" />
<div class="hamburger"><div></div></div>
<div class="menu">
<div>
<div>
<!-- Menu Content Grid -->
<div class="footer-grid">
<!-- About/Over Ons -->
<div class="footer-content">
<div class="menu-video-wrap">
<video
src="img/menu_vid_overons.mov"
muted
preload
autoplay
loop="yes"
></video>
<div class="vid-text">
<a href="#"
><h1>Over Ons</h1>
<h5>Historie en filosofie</h5></a
>
</div>
<div class="menu-overlay"></div>
</div>
</div>
<!-- Our Vineyard / Onze Wijngaard -->
<div class="footer-content">
<div class="menu-video-wrap">
<video
src="img/menu_vid_wijngaard.mp4"
muted
preload
autoplay
loop="yes"
></video>
<div class="vid-text">
<a href="#"
><h1>Onze Wijngaard</h1>
<h5>Proeverijen, evenementen en vrijwilligers</h5></a
>
</div>
<div class="menu-overlay"></div>
</div>
</div>
<!-- Wines / Wijnen -->
<div class="footer-content">
<div class="menu-video-wrap">
<video
src="img/menu_vid_wijnen.mp4"
muted
preload
autoplay
loop="yes"
></video>
<div class="vid-text">
<a href="#"
><h1>Wijnen</h1>
<h5>Stille en mousserende wijnen</h5></a
>
</div>
<div class="menu-overlay"></div>
</div>
</div>
<!-- Contact -->
<div class="footer-content">
<div class="menu-video-wrap">
<video
src="img/menu_vid_contact.mp4"
autoplay
loop="yes"
muted
preload
></video>
<div class="vid-text">
<a href="#"
><h1>
Contact
</h1>
<h5>Neem contact op</h5>
</a>
</div>
<div class="menu-overlay"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Showcase Hero -->
<header id="showcase">
<div class="showcase-overlay"></div>
<div class="container showcase-container">
<h1>Wijngaard de Frysling</h1>
<p>De Noorderlijkste Wijngaard van Nederland</p>
</div>
</header>
</body>
</html>
Here is the css, below I will also post the scss which appears more readable:
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
ul {
list-style: none;
}
body {
font-family: "Lora", sans-serif;
}
.container {
max-width: 960px;
margin: auto;
overflow: hidden;
padding: 0 3rem;
}
#logo {
width: 150px;
margin-top: 1rem;
margin-left: 3rem;
position: absolute;
z-index: 1;
}
#shopping-cart {
margin-top: 0.5rem;
position: absolute;
right: 6%;
width: 40px;
z-index: 1;
}
.menu-wrap {
position: absolute;
top: 0;
right: 5%;
z-index: 1;
}
.menu-wrap .toggler {
position: absolute;
top: 0;
left: 0;
z-index: 2;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0;
}
.menu-wrap .hamburger {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 60px;
height: 60px;
padding: 1rem;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.menu-wrap .hamburger > div {
position: relative;
-webkit-box-flex: 0;
-ms-flex: none;
flex: none;
width: 100%;
height: 2.5px;
background: #fff;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.menu-wrap .hamburger > div::before, .menu-wrap .hamburger > div::after {
content: "";
position: absolute;
z-index: 1;
top: -10px;
width: 100%;
height: 2.5px;
background: inherit;
}
.menu-wrap .hamburger > div::after {
top: 10px;
}
.menu-wrap .menu {
position: fixed;
left: 0;
width: 100%;
overflow: hidden;
visibility: hidden;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
bottom: 0;
}
.menu-wrap .menu > div {
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transition: all 0.4s ease;
transition: all 0.4s ease;
width: 100%;
height: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-flex: 0;
-ms-flex: none;
flex: none;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
bottom: 0;
}
.menu-wrap .menu > div > div {
opacity: 0;
-webkit-transition: opacity 0.4s easy;
transition: opacity 0.4s easy;
}
.menu-wrap .menu > div > div .footer-grid {
display: -ms-grid;
display: grid;
-ms-grid-columns: (25vw)[4];
grid-template-columns: repeat(4, 25vw);
-ms-grid-rows: 25vh;
grid-template-rows: 25vh;
grid-gap: 1rem;
bottom: 0;
}
.menu-wrap .menu > div > div .footer-grid .footer-content {
display: inline-block;
position: relative;
bottom: 0;
}
.menu-wrap .menu > div > div .footer-grid .footer-content .menu-video-wrap {
width: 100%;
height: 100%;
overflow: hidden;
}
.menu-wrap .menu > div > div .footer-grid .footer-content .menu-video-wrap video {
-o-object-fit: fill;
object-fit: fill;
width: 100%;
height: 100%;
}
.menu-wrap .menu > div > div .footer-grid .footer-content .menu-video-wrap .menu-overlay {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background: #000;
z-index: 1;
opacity: 0.5;
}
.menu-wrap .menu > div > div .footer-grid .footer-content .menu-video-wrap .menu-overlay:hover {
opacity: 0;
}
.menu-wrap .menu > div > div .footer-grid .footer-content .menu-video-wrap .vid-text {
position: absolute;
z-index: 3;
margin: 0 auto;
left: 0;
right: 0;
top: 40%;
text-align: center;
}
.menu-wrap .menu > div > div .footer-grid .footer-content .menu-video-wrap .vid-text a {
color: #fff;
text-decoration: none;
z-index: 3;
}
/* Toggler Animation */
.menu-wrap .toggler:checked + .hamburger > div {
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
/* Turns lines into X */
.menu-wrap .toggler:checked + .hamburger > div:before,
.menu-wrap .toggler:checked + .hamburger > div:after {
top: 0;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
/* Rotate on Hover when checked */
.menu-wrap .toggler:checked:hover + .hamburger > div {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
/* Show Menu */
.menu-wrap .toggler:checked ~ .menu {
visibility: visible;
}
.menu-wrap .toggler:checked ~ .menu > div {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition-duration: 0.75s;
transition-duration: 0.75s;
}
.menu-wrap .toggler:checked ~ .menu > div > div {
opacity: 1;
-webkit-transition: opacity 0.4s ease 0.4s;
transition: opacity 0.4s ease 0.4s;
}
#showcase {
height: 100vh;
}
#showcase:before {
content: "";
background: url("https://images.pexels.com/photos/39511/purple-grapes-vineyard-napa-valley-napa-vineyard-39511.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260") no-repeat center center/cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
#showcase .showcase-overlay {
background: rgba(0, 0, 0, 0.3);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
#showcase .showcase-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
text-align: center;
height: 100%;
margin: auto;
color: #fff;
z-index: 1;
position: relative;
}
#showcase .showcase-container h1 {
line-height: 1.4;
font-size: 4.5rem;
}
#showcase .showcase-container p {
line-height: 1.4;
font-weight: bold;
font-size: 1.5rem;
}
/*# sourceMappingURL=style.css.map */
Here is the SCSS code:
// Variables
$primary-color: #f6f5e8;
$secondary-color: green;
$overlay-color: #333;
$menu-speed: 0.75s;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
ul {
list-style: none;
}
body {
font-family: "Lora", sans-serif;
}
.container {
max-width: 960px;
margin: auto;
overflow: hidden;
padding: 0 3rem;
}
// Logo
#logo {
width: 150px;
margin-top: 1rem;
margin-left: 3rem;
position: absolute;
z-index: 1;
}
// Shopping Cart
#shopping-cart {
margin-top: 0.5rem;
position: absolute;
right: 6%;
width: 40px;
z-index: 1;
}
// Hamburger Menu
.menu-wrap {
position: absolute;
top: 0;
right: 5%;
z-index: 1;
.toggler {
position: absolute;
top: 0;
left: 0;
z-index: 2;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0;
}
.hamburger {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 60px;
height: 60px;
padding: 1rem;
display: flex;
align-items: center;
justify-content: center;
> div {
position: relative;
flex: none;
width: 100%;
height: 2.5px;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.4s ease;
&::before,
&::after {
content: "";
position: absolute;
z-index: 1;
top: -10px;
width: 100%;
height: 2.5px;
background: inherit;
}
&::after {
top: 10px;
}
}
}
.menu {
position: fixed;
left: 0;
width: 100%;
overflow: hidden;
visibility: hidden;
display: flex;
align-items: center;
justify-content: center;
bottom: 0;
> div {
transform: scale(0);
transition: all 0.4s ease;
width: 100%;
height: 100%;
display: flex;
flex: none;
align-items: center;
justify-content: center;
bottom: 0;
> div {
opacity: 0;
transition: opacity 0.4s easy;
.footer-grid {
display: grid;
grid-template-columns: repeat(4, 25vw);
grid-template-rows: 25vh;
grid-gap: 1rem;
bottom: 0;
.footer-content {
display: inline-block;
position: relative;
bottom: 0;
.menu-video-wrap {
width: 100%;
height: 100%;
overflow: hidden;
video {
object-fit: fill;
width: 100%;
height: 100%;
}
.menu-overlay {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background: #000;
z-index: 1;
opacity: 0.5;
&:hover {
opacity: 0;
}
}
.vid-text {
position: absolute;
z-index: 3;
margin: 0 auto;
left: 0;
right: 0;
top: 40%;
text-align: center;
a {
color: #fff;
text-decoration: none;
z-index: 3;
}
}
}
}
}
}
}
}
}
/* Toggler Animation */
.menu-wrap .toggler:checked + .hamburger > div {
transform: rotate(135deg);
}
/* Turns lines into X */
.menu-wrap .toggler:checked + .hamburger > div:before,
.menu-wrap .toggler:checked + .hamburger > div:after {
top: 0;
transform: rotate(90deg);
}
/* Rotate on Hover when checked */
.menu-wrap .toggler:checked:hover + .hamburger > div {
transform: rotate(225deg);
}
/* Show Menu */
.menu-wrap .toggler:checked ~ .menu {
visibility: visible;
}
.menu-wrap .toggler:checked ~ .menu > div {
transform: scale(1);
transition-duration: $menu-speed;
}
.menu-wrap .toggler:checked ~ .menu > div > div {
opacity: 1;
transition: opacity 0.4s ease 0.4s;
}
// Showcase
#showcase {
height: 100vh;
&:before {
content: "";
// Placeholder background
background: url("https://images.pexels.com/photos/39511/purple-grapes-vineyard-napa-valley-napa-vineyard-39511.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260")
no-repeat center center/cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.showcase-overlay {
background: rgba($color: #000000, $alpha: 0.3);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.showcase-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 100%;
margin: auto;
color: #fff;
z-index: 1;
position: relative;
h1 {
line-height: 1.4;
font-size: 4.5rem;
}
p {
line-height: 1.4;
font-weight: bold;
font-size: 1.5rem;
}
}
}
This is because your main container overlaying all your elements with z-index: 1;.
Try to remove z-index from this and you will be fine:
#showcase .showcase-container {
z-index: 1;
}
I have a question about my responsive website.
I deployed my project to web server. In my local server and PC web server, I checked in google chrome dev tool, and z-index worked properly. The menu bar slides from the left side to the right side.
But when I checked in the real browser from a smartphone, the menu field did not show up. Background color and letter color are invisible.
When I tap each a tags (tags are invisible but I guessed each position.), I could jump to each page such as a result page, login page, and homepage. So I guess the menu bar is at the top of the screen.
The question is that,
when I see a responsive website, the menu bar doesn't appear and is
invisible. But a tags inside the menu are working properly so, I
cannot figure out what this problem is coming from.
.logo {
line-height: 50px;
float: left;
text-transform: uppercase;
color: #fff;
}
.header {
height: 50px;
background: #2D2524;
padding: 0 20px;
color: white;
position: -webkit-sticky;
position: sticky;
top: 0;
z-index: 1000;
}
.header2 {
display: none;
}
.menu {
float: right;
line-height: 50px;
}
.menu a {
color: #fff;
text-transform: uppercase;
text-decoration: none;
padding: 0 10px;
-webkit-transition: 0.4s;
transition: 0.4s;
}
.background-img {
background: url("../LPImages/karina-lago-wEucG_sLRsY-unsplash.jpg");
background-size: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
width: 100%;
position: relative;
height: 70vh;
}
.main_search {
position: absolute;
top: 70%;
left: 50%;
-webkit-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 70%;
text-align: center;
}
.search_text {
background: #232323;
opacity: 0.9;
padding-left: 10px;
border: solid 3px #fff;
font-size: 16px;
line-height: 30px;
width: 35%;
height: 3rem;
font-weight: 400;
color: #fff;
}
.search_text:focus {
outline: none;
}
.Genre {
color: #fff;
background: #232323;
opacity: 0.9;
border: solid 3px #fff;
padding-left: 5px;
font-size: 16px;
line-height: 30px;
width: 20%;
height: 3.4rem;
font-weight: 400;
text-transform: uppercase;
}
.Genre:focus {
outline: none;
}
.search_date {
background: #232323;
opacity: 0.8;
margin-right: 15px;
padding-left: 15px;
color: #fff;
border: solid 3px #fff;
font-size: 16px;
width: 20%;
font-weight: 400;
height: 3rem;
}
.search_date:focus {
outline: none;
}
.search_icon {
color: #fff;
}
.show-menu-btn, .hide-menu-btn {
-webkit-transition: 0.4s;
transition: 0.4s;
font-size: 20px;
cursor: pointer;
display: none;
}
.show-menu-btn {
float: right;
}
.show-menu-btn i {
line-height: 50px;
}
.menu a:hover,
.show-menu-btn:hover,
.hide-menu-btn:hover {
color: grey;
}
.paragrah {
height: 50%;
width: 30%;
color: white;
margin-left: 5em;
margin-top: 7em;
margin-bottom: 20em;
font-size: 20px;
background-color: rgba(0, 0, 0, 0.7);
text-align: justify;
}
#chk {
position: absolute;
visibility: hidden;
z-index: -1111;
}
/*.content {
padding: o 20px;
img {
width: 100%;
max-width: 700px;
margin: 20px 0;
}
}*/
#media screen and (max-width: 800px) {
.header {
display: none;
}
.search {
display: none;
}
.header2 {
display: block;
width: 100%;
max-width: 100%;
-webkit-box-shadow: none;
box-shadow: none;
position: fixed;
height: 50px;
background: #2D2524;
overflow: hidden;
z-index: 10;
}
.background-img {
width: 100%;
}
.main {
margin: 0 auto;
display: block;
height: 100%;
margin-top: 60px;
}
.mainInner {
display: table;
height: 100%;
width: 100%;
text-align: center;
}
.mainInner div {
display: table-cell;
vertical-align: middle;
font-size: 3em;
font-weight: bold;
letter-spacing: 1.25px;
}
#sidebarSearch {
position: relative;
height: 100%;
left: 0;
width: 100%;
margin-top: 50px;
-webkit-transform: translateX(1500px);
transform: translateX(1500px);
-webkit-transition: -webkit-transform 0.6s ease-in-out;
transition: -webkit-transform 0.6s ease-in-out;
transition: transform 0.6s ease-in-out;
transition: transform 0.6s ease-in-out, -webkit-transform 0.6s ease-in-out;
background: #000000;
color: #fff;
position: fixed;
text-align: center;
}
.sidebarIconSearch i {
color: #fff;
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: pointer;
position: absolute;
top: 16px;
right: 25px;
z-index: 99;
font-size: 20px;
}
input[type="checkbox"]:checked ~ #sidebarSearch {
-webkit-transform: translateX(0);
transform: translateX(0);
}
input[type="checkbox"]:checked ~ #sidebarSearch ~ .sidebarIconToggle {
display: none;
}
.openSidebarSearch {
float: right;
}
.search-title {
font-size: 20px;
font-weight: bold;
margin: 20px 0 10px;
}
.search_text {
outline: none;
height: 30px;
width: 60%;
border: solid 3px #fff;
background: none;
border-radius: 30px;
color: #fff;
padding: 0 20px;
font-size: 16px;
}
.tag-list {
color: #000000;
margin: 0;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
list-style: none;
padding: 10px;
}
.tag-list li {
background: #fff;
border-radius: 30px;
margin: 4px;
height: 24px;
width: 80px;
-ms-flex-pack: distribute;
justify-content: space-around;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
font-size: 12px;
}
.Category dt {
background: #fff;
width: 80px;
height: 80px;
border-radius: 50%;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.Category dt img {
width: 50px;
height: 50px;
}
.Category dd {
text-transform: uppercase;
font-weight: bold;
margin: 0 auto;
}
.Category-list {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: space-evenly;
-ms-flex-pack: space-evenly;
justify-content: space-evenly;
}
.Day-box {
outline: none;
height: 30px;
width: 200px;
border: solid 3px #fff;
background: none;
border-radius: 30px;
color: #fff;
padding: 0 20px;
font-size: 16px;
}
#sidebarMenu {
position: relative;
width: 100%;
height: 100%;
position: fixed;
left: 0;
margin-top: 50px;
-webkit-transform: translateX(-1500px);
transform: translateX(-1500px);
-webkit-transition: -webkit-transform 0.6s ease-in-out;
transition: -webkit-transform 0.6s ease-in-out;
transition: transform 0.6s ease-in-out;
transition: transform 0.6s ease-in-out, -webkit-transform 0.6s ease-in-out;
background: #000000;
}
.sidebarMenuInner {
position: absolute;
text-align: center;
top: 40%;
left: 50%;
-webkit-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
margin: 0;
padding: 0;
}
.sidebarMenuInner li {
list-style: none;
color: #fff;
text-transform: uppercase;
font-weight: bold;
font-size: 20px;
padding: 30px;
cursor: pointer;
}
.sidebarMenuInner li a {
color: #fff;
text-transform: uppercase;
font-weight: bold;
cursor: pointer;
text-decoration: none;
}
input[type="checkbox"]:checked ~ #sidebarMenu {
-webkit-transform: translateX(0);
transform: translateX(0);
}
input[type="checkbox"]:checked ~ #sidebarMenu ~ .sidebarIconSearch {
display: none;
}
input[type="checkbox"]:checked ~ #sidebarMenu ~ #sidebarSearch {
display: none;
}
input[type=checkbox] {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
display: none;
}
.sidebarIconToggle {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: pointer;
position: absolute;
z-index: 99;
height: 100%;
width: 100%;
top: 18px;
left: 20px;
height: 22px;
width: 22px;
}
.spinner {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
position: absolute;
height: 3px;
width: 100%;
background-color: #fff;
}
.horizontal {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
.diagonal.part-1 {
position: relative;
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
float: left;
}
.diagonal.part-2 {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .horizontal {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
opacity: 0;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-1 {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
margin-top: 8px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-2 {
-webkit-transition: all 0.3s;
transition: all 0.3s;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transform: rotate(-135deg);
transform: rotate(-135deg);
margin-top: -9px;
}
}
.image img {
border: 1px solid white;
}
.event-name {
font-size: 20px;
color: white;
}
.heart {
margin-top: -20px;
margin-left: 17rem;
}
.event-date {
font-size: 20px;
color: #FD8700;
}
.card-info {
color: white;
font-size: 18px;
}
.save-mark {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.button {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: 300px;
margin-left: 120px;
}
.seemore-btn {
margin-top: 4rem;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.seemore-btn a {
color: white;
border-radius: 30px;
font-size: 24px;
padding: 4px 20px 4px 20px;
border: 0;
cursor: pointer;
text-decoration: none;
background: #7206F7;
}
.category-container {
margin-top: 8rem;
}
.category-card {
padding: 0 50px 80px;
margin: 0 auto;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
text-align: center;
-webkit-box-pack: space-evenly;
-ms-flex-pack: space-evenly;
justify-content: space-evenly;
}
.category-card p {
text-transform: uppercase;
margin-top: 20px;
color: #ffffff;
font-size: 35px;
}
.category-image {
overflow: hidden;
border-radius: 50%;
width: 220px;
height: 220px;
border: solid #ffffff 1px;
}
.category-image img {
width: 220px;
height: 220px;
-o-object-fit: cover;
object-fit: cover;
border-radius: 50%;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
-webkit-transform: scale(1);
transform: scale(1);
}
.category-image img:hover {
-webkit-transform: scale(1.1, 1.1);
transform: scale(1.1, 1.1);
}
#media screen and (max-width: 800px) {
.category-card {
display: block;
}
.category-card-content {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
margin-bottom: 70px;
position: relative;
}
.category-card-content p {
position: absolute;
top: 43%;
left: 50%;
-webkit-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
font-size: 45px;
}
.category-image {
margin: 0 auto;
border: solid 1px #ffffff;
}
.category-image img {
opacity: 0.7;
}
}
.use_contents {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.use_contents img {
margin-right: 7rem;
width: 20%;
}
.Description {
text-align: center;
width: 30%;
}
.Description p {
text-align: center;
font-size: 19px;
margin-top: 0.5rem;
color: #c7c7c7;
}
.register-btn {
margin-top: 4rem;
}
.register-btn a {
background-color: #F70661;
text-decoration: none;
color: white;
margin-top: 10px;
border-radius: 30px;
font-size: 24px;
padding: 4px 20px 4px 20px;
border: 0;
cursor: pointer;
}
.find_func {
margin: 1rem;
}
.use_contents2 img {
margin-left: 7rem;
margin-right: 0;
}
.start {
margin: 4rem 0 10rem;
text-align: center;
}
.right {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
margin: 0 0 0 auto;
}
#media screen and (max-width: 800px) {
.use_contents {
padding: 20px;
}
.use_contents img {
margin-right: 1rem;
width: 40%;
}
.use_contents2 {
margin-left: 0;
}
.use_contents2 img {
margin-right: 0;
margin-left: 1rem;
}
.Description {
width: 100%;
}
h4 {
margin: 0;
}
}
.login {
background: url("../LPImages/danny-howe-bn-D2bCvpik-unsplash.jpg");
background-size: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
width: 100%;
position: relative;
height: 80vh;
}
.login-contents {
background: rgba(0, 0, 0, 0.4);
height: 80vh;
width: 100%;
text-align: center;
}
.login-base {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translateY(-50%) translateX(-50%);
transform: translateY(-50%) translateX(-50%);
}
.login-base h2 {
margin: 0;
}
.login-erea p {
font-size: 18px;
color: white;
}
.login-box {
margin: 12px 0;
padding: 0 20px;
font-size: 12px;
color: #fff;
background: none;
border-radius: 30px;
height: 2.3em;
width: 25em;
outline: none;
border: #fff solid 3px;
}
.login-link {
margin-top: 2.5rem;
}
.login-link a {
background-color: #0FCC41;
color: white;
margin-top: 10px;
border-radius: 30px;
font-size: 24px;
padding: 4px 38px 4px 38px;
border: 0;
cursor: pointer;
text-decoration: none;
}
.forgot {
margin-top: 0.8rem;
}
.forgot a {
font-size: 18px;
color: white;
text-decoration: none;
border-bottom: 0.5px solid white;
}
.sns-icon-erea {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
margin: 2rem 0 0.5rem;
}
.sns-icon {
position: relative;
height: 50px;
width: 50px;
border-radius: 50%;
margin: 0 10px;
cursor: pointer;
}
.sns-icon i {
color: #fff;
position: absolute;
top: 50%;
left: 52%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
.footer {
height: 50vh;
width: 100%;
background-color: #2D2524;
}
/*#import "./footer";*/
* {
margin: 0;
padding: 0;
font-family: 'Josefin Sans', sans-serif;
font-weight: 100;
}
body {
background-color: black;
}
h2 {
color: white;
text-align: center;
margin-bottom: 3rem;
font-size: 38px;
}
h3 {
color: white;
font-size: 33px;
}
h4 {
color: white;
font-size: 23px;
margin-top: 2rem;
}
.face {
background: #305097;
}
.twi {
background: #00aced;
}
.goo {
background: #db4a39;
}
/*# sourceMappingURL=main.css.map */
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" rel="stylesheet">
<link rel="stylesheet" href="../css/main.css">
<link rel="stylesheet" href="https://unpkg.com/swiper/css/swiper.css">
<link rel="stylesheet" href="../css/swiper.css">
<link href="https://fonts.googleapis.com/css?family=Lato&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap" rel="stylesheet">
<title>landing page</title>
</head>
<body>
<div class="header">
<h1 class="logo">Dark Code</h1>
<input type="checkbox" id="chk">
<label for="chk" class="show-menu-btn">
<i class="fas fa-bars" style="color: white;"></i>
</label>
<ul class="menu">
<div class="menu-list">
Register
Events
Login
<label for="chk" class="hide-menu-btn">
<i class="fas fa-times" style="color: white;"></i>
</label>
</div>
</ul>
</div>
<div class="header2">
<input type="checkbox" class="openSidebarMenu" id="openSidebarMenu">
<label for="openSidebarMenu" class="sidebarIconToggle">
<div class="spinner diagonal part-1"></div>
<div class="spinner horizontal"></div>
<div class="spinner diagonal part-2"></div>
</label>
<div id="sidebarMenu">
<ul class="sidebarMenuInner">
<li>Home</li>
<li>Events</li>
<li>Profile</li>
<li>Log out</li>
</ul>
</div>
<input type="checkbox" class="openSidebarSearch" id="openSidebarSearch">
<label for="openSidebarSearch" class="sidebarIconSearch">
<i class="fas fa-search search_icon"></i>
</label>
<div id="sidebarSearch">
<div class="search-erea">
<div class="search-title">Enter the name of event</div>
<input type="text" class="search_text">
<div class="search-title">Choose tags</div>
<ul class="tag-list">
<li>Tag</li>
<li>Tag</li>
<li>Tag</li>
<li>Tag</li>
</ul>
<ul class="tag-list">
<li>Tag</li>
<li>Tag</li>
<li>Tag</li>
<li>Tag</li>
</ul>
</div>
<div class="search-erea">
<div class="search-title">Categorys</div>
<div class="Category-list">
<dl class="Category">
<dt><img src="./image/martini.png" alt="bar-img"></dt>
<dd>bar</dd>
</dl>
<dl class="Category">
<dt><img src="./image/beer.png" alt="pub-img"></dt>
<dd>pub</dd>
</dl>
<dl class="Category">
<dt><img src="./image/dj.png" alt="club-img"></dt>
<dd>club</dd>
</dl>
</div>
</div>
<div class="search-erea">
<div class="search-title">Day</div>
<input type="text" class="Day-box">
</div>
</div>
</div>
<div class="background-img">
<div class="main_search">
<div class="search_content">
<form action="#" class="search">
<input type="text" class="search_text" placeholder="Enter the key words !">
<select name="select" id="select" class="Genre">
<option value="" hidden">genre</option>
<option value="1">bar</option>
<option value="2">pub</option>
<option value="3">club</option>
</select>
<input type="date" class="search_date">
<i class="fas fa-search search_icon"></i>
</div>
</div>
</div>
<script src="https://unpkg.com/swiper/js/swiper.js"></script>
<script src="https://unpkg.com/swiper/js/swiper.min.js"></script>
<script src="./js/swiper.min.js"></script>
<script>
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'horizontal',
slidesPerView: 4,
spaceBetween: 10,
centeredSlides : true,
loop: true,
// Navigation arrows
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
})
</script>
</body>
</html>
From a smartphone, it doesn't work, but if you check from PC, it works so I hope you can check this link from a smartphone.
thank you.
I checked both iOS and Android chrome browser.
And this issue is happening only in iOS.
So please check by iPhone.
I also experience this issue on iOS devices time to time.
z-index behaves different on iOS (no matter the browser). Even if you correctly index content on Z axis, it won't be shown correctly on iOS devices.
Workaround is, giving container div a higher z-index than background.
In your case #sidebarMenu {z-index: 100;} should work.
This looks like it might be an issue with iOS.
According to the specs, the CSS property z-index should only not work if an element has the default positioning:
position: static
Consequently, to ensure that z-index works, any of the following may be applied to the element (which we can see you're already doing):
position: relative
position: absolute
position: fixed
position: sticky
Further Reading:
position: static
The element is positioned according to the normal flow of the document. The top, right, bottom, left, and z-index properties have no
effect. This is the default value.
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/position#values
Helow Guys, I just created a menu links design by following some tutorial in YT, however, I encountered some error, while hovering the links it goes to the logo image space, making the image logo can't see it clearly. What I want is while hovering the links it creates a padding or margin so that the image logo will not disturb and stay the logo where he is. Here's my code
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.firstNav > a {
position: relative;
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: 0.5s;
color: #000;
}
nav:hover a {
transform: scale(1.5);
opacity: .6;
filter: blur(4px);
}
nav .firstNav a:hover {
transform: scale(2);
opacity: 1;
filter: blur(0);
}
nav .firstNav a::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #2575aa;
transition: 0.5s;
transform-origin: right;
transform: scaleX(0);
z-index: -1;
}
nav .firstNav a:hover::before{
transition: 0.5s;
transform-origin: left;
transform: scaleX(1);
}
<nav>
<div class="firstNav">
Home
Blog
Portfolio
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
Progress
About
Contact
</div>
</nav>
I think given what you are trying to do it will always invade the space of the logo, so an alternative to Smollet777's answer is that you can adjust its behaviour to push out the items so it wont matter what the width of the text content is.
You can split the nav items in two to keep the logo in a fixed placed and use css transitions to expand the other items like so:
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
width: 800px;
}
.blurLink {
position: relative;
font-family: "Montserrat", sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: font-size 1s, padding 1s;
color: #000;
}
.blurLink:hover {
font-size: 32px;
padding: 0 20px;
background: #2575aa;
}
.navGroup {
width: 40%;
display: flex;
justify-content: flex-end;
align-items: center;
}
.navGroup2 {
width: 40%;
display: flex;
justify-content: flex-start;
align-items: center;
}
<nav>
<div class="firstNav">
<div class="navGroup">
Home
Blog
Portfolio
</div>
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
<div class="navGroup2">
Progress
About
Contact
</div>
</div>
</nav>
You can use element:nth-child(index) to target specific element in CSS.
nav .firstNav a:nth-child(3):hover {
position: relative;
left: -55px;
}
nav .firstNav a:nth-child(5):hover {
position: relative;
right: -55px;
}
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.firstNav>a {
position: relative;
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: 0.5s;
color: #000;
}
nav:hover a {
transform: scale(1.5);
opacity: .6;
filter: blur(4px);
}
nav .firstNav a:hover {
transform: scale(2);
opacity: 1;
filter: blur(0);
}
nav .firstNav a::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #2575aa;
transition: 0.5s;
transform-origin: right;
transform: scaleX(0);
z-index: -1;
}
nav .firstNav a:hover::before {
transition: 0.5s;
transform-origin: left;
transform: scaleX(1);
}
<nav>
<div class="firstNav">
Home
Blog
Portfolio
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
Progress
About
Contact
</div>
</nav>
Use this and you'll be ok.
.firstNav>a:nth-of-type(3):hover {
transform: translateX(-55px) scale(2);
}
.firstNav>a:nth-of-type(4):hover {
transform: translateX(55px) scale(2);
}
I am trying to make the hamburger navigation elements to align themselves evenly on the whole 100vh area, I tried using space-between but it did not work. Is it because I used vh instead of px as my measure? Should I be using aling-content instead? How does flexbox' justify-content work?
* {
margin: 0;
padding: 0;
-webkit-tap-highlight-color: transparent;
}
.mobile {
position: fixed;
top: 0;
left: 0;
display: flex;
flex-direction: column;
align-items: center;
visibility: hidden;
background: rgba(255, 255, 255, 0);
width: 100vw;
height: 100vh;
z-index: 1;
transition: visibility 1s, background 1s;
transition-delay: .5s;
font-family: "Georgia";
}
.mobile a {
text-decoration: none;
color: black;
}
.mobilenav {
visibility: hidden;
list-style: none;
opacity: 0;
transition: visibility .5s, opacity .5s;
}
.mobilenav.active {
visibility: visible;
opacity: 1;
transition: visibility .5s, opacity .5s;
transition-delay: .5s;
}
.hamburger {
align-items: center;
display: flex;
width: 25px;
height: 15px;
margin-right: 50px;
cursor: pointer;
display: none;
z-index: 2;
}
.hamburger.active .line {
background: rgba(0, 0, 0, 0);
transition: .2s;
}
.hamburger.active .line::before {
transform: rotate(45deg);
top: 0;
transition: .5s;
}
.hamburger.active .line::after {
transform: rotate(135deg);
top: 0;
transition: .5s;
}
.line {
position: relative;
background-color: black;
width: 100%;
height: 1px;
transition: .5s;
}
.line::before,
.line::after {
position: absolute;
content: "";
height: 1px;
width: 100%;
background-color: black;
}
.line::after {
top: 6px;
transition: .5s;
}
.line::before {
top: -6px;
transition: .5s;
}
.nav {
justify-content: flex-end;
display: flex;
flex-wrap: wrap;
letter-spacing: 1px;
padding: 30px 0;
margin-right: 50px;
}
.nav li {
text-align: center;
font-family: "Georgia";
padding-left: 60px;
font-size: .8em;
font-weight: normal;
letter-spacing: 1px;
list-style: none;
}
.nav li a {
position: relative;
text-decoration: none;
color: inherit;
transition: color .5s;
}
.nav li a::before {
top: 2em;
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 0;
left: 0;
background-color: black;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.2s;
transition: all 0.2s;
}
.nav li a:hover::before {
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.nav, nav {
align-items: center;
display: flex;
}
nav .logo {
margin-left: 50px;
display: flex;
justify-content: flex-start;
flex: 1;
font-family: Georgia, serif;
font-size: .8em;
padding: 30px 0;
font-weight: bold;
letter-spacing: 3px;
}
.sublogo {
font-weight: lighter;
margin-left: 10px;
}
.sublogo::before {
content: '|';
margin-right: 10px;
}
#media (max-width: 1120px) {
.nav {
display: none;
}
.hamburger {
display: flex;
-ms-transform: scale(1.2, 1.2);
-webkit-transform: scale(1.2, 1.2);
transform: scale(1.2, 1.2);
}
nav .logo {
font-size: 1em;
letter-spacing: 3px;
transition: visibility .5s, opacity .5s;
}
nav .logo .sublogo {
letter-spacing: 3px;
}
.logo.active {
visibility: hidden;
opacity: 0;
transition: visibility .5s, opacity .5s;
}
.mobile.active {
display: flex;
visibility: visible;
background: rgba(255, 255, 255, 1);
transition: background 1s;
}
}
#media (max-width: 600px) {
nav .logo {
font-size: 1em;
letter-spacing: 3px;
}
.sublogo {
display: none;
}
}
/*--END OF NAV--*/
.picture {
width: 100%;
height: 400px;
background-image: url(img/slider.jpg);
background-size: cover;
background-position: top;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="stylesheet.css">
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.hamburger').click(function(){
$('.hamburger').toggleClass('active');
$('.logo').toggleClass('active');
$('.mobile').toggleClass('active');
$('.mobilenav').toggleClass('active');
})
})
</script>
<meta charset="utf-8">
<title>CSS & HTML NAVIGATION</title>
</head>
<body>
<nav>
<div class="logo">
navigation.
<div class="sublogo">
this is my first example
</div>
</div>
<ul class="nav">
<li>html</li>
<li>css</li>
<li>javascript</li>
<li>python</li>
<li>c++</li>
<li>php</li>
</ul>
<div class="hamburger">
<div class="line">
</div>
</div>
<div class="mobile">
<ul class="mobilenav">
<li>html</li>
<li>css</li>
<li>javascript</li>
<li>python</li>
<li>c++</li>
<li>php</li>
</ul>
</div>
</nav>
<div class="picture">
</div>
</body>
</html>
You have to set the height on the mobilenav class. Set the element to flex and their flex-direction: column and justify-content: space-evenly
The height of a block element defaults to the height of the block's content so, you have to specify a height in order for justify-content to work.
Hope this helps.
* {
margin: 0;
padding: 0;
-webkit-tap-highlight-color: transparent;
}
.mobile {
position: fixed;
top: 0;
left: 0;
display: flex;
flex-direction: column;
align-items: center;
visibility: hidden;
background: rgba(255, 255, 255, 0);
width: 100vw;
height: 100vh;
z-index: 1;
transition: visibility 1s, background 1s;
transition-delay: .5s;
font-family: "Georgia";
}
.mobile a {
text-decoration: none;
color: black;
}
.mobilenav {
visibility: hidden;
list-style: none;
opacity: 0;
transition: visibility .5s, opacity .5s;
height: 100vh;
justify-content: space-evenly;
display: flex;
flex-direction: column;
}
.mobilenav.active {
visibility: visible;
opacity: 1;
transition: visibility .5s, opacity .5s;
transition-delay: .5s;
}
.hamburger {
align-items: center;
display: flex;
width: 25px;
height: 15px;
margin-right: 50px;
cursor: pointer;
display: none;
z-index: 2;
}
.hamburger.active .line {
background: rgba(0, 0, 0, 0);
transition: .2s;
}
.hamburger.active .line::before {
transform: rotate(45deg);
top: 0;
transition: .5s;
}
.hamburger.active .line::after {
transform: rotate(135deg);
top: 0;
transition: .5s;
}
.line {
position: relative;
background-color: black;
width: 100%;
height: 1px;
transition: .5s;
}
.line::before,
.line::after {
position: absolute;
content: "";
height: 1px;
width: 100%;
background-color: black;
}
.line::after {
top: 6px;
transition: .5s;
}
.line::before {
top: -6px;
transition: .5s;
}
.nav {
justify-content: flex-end;
display: flex;
flex-wrap: wrap;
letter-spacing: 1px;
padding: 30px 0;
margin-right: 50px;
}
.nav li {
text-align: center;
font-family: "Georgia";
padding-left: 60px;
font-size: .8em;
font-weight: normal;
letter-spacing: 1px;
list-style: none;
}
.nav li a {
position: relative;
text-decoration: none;
color: inherit;
transition: color .5s;
}
.nav li a::before {
top: 2em;
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 0;
left: 0;
background-color: black;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.2s;
transition: all 0.2s;
}
.nav li a:hover::before {
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.nav, nav {
align-items: center;
display: flex;
}
nav .logo {
margin-left: 50px;
display: flex;
justify-content: flex-start;
flex: 1;
font-family: Georgia, serif;
font-size: .8em;
padding: 30px 0;
font-weight: bold;
letter-spacing: 3px;
}
.sublogo {
font-weight: lighter;
margin-left: 10px;
}
.sublogo::before {
content: '|';
margin-right: 10px;
}
#media (max-width: 1120px) {
.nav {
display: none;
}
.hamburger {
display: flex;
-ms-transform: scale(1.2, 1.2);
-webkit-transform: scale(1.2, 1.2);
transform: scale(1.2, 1.2);
}
nav .logo {
font-size: 1em;
letter-spacing: 3px;
transition: visibility .5s, opacity .5s;
}
nav .logo .sublogo {
letter-spacing: 3px;
}
.logo.active {
visibility: hidden;
opacity: 0;
transition: visibility .5s, opacity .5s;
}
.mobile.active {
display: flex;
visibility: visible;
background: rgba(255, 255, 255, 1);
transition: background 1s;
}
}
#media (max-width: 600px) {
nav .logo {
font-size: 1em;
letter-spacing: 3px;
}
.sublogo {
display: none;
}
}
/*--END OF NAV--*/
.picture {
width: 100%;
height: 400px;
background-image: url(img/slider.jpg);
background-size: cover;
background-position: top;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="stylesheet.css">
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.hamburger').click(function(){
$('.hamburger').toggleClass('active');
$('.logo').toggleClass('active');
$('.mobile').toggleClass('active');
$('.mobilenav').toggleClass('active');
})
})
</script>
<meta charset="utf-8">
<title>CSS & HTML NAVIGATION</title>
</head>
<body>
<nav>
<div class="logo">
navigation.
<div class="sublogo">
this is my first example
</div>
</div>
<ul class="nav">
<li>html</li>
<li>css</li>
<li>javascript</li>
<li>python</li>
<li>c++</li>
<li>php</li>
</ul>
<div class="hamburger">
<div class="line">
</div>
</div>
<div class="mobile">
<ul class="mobilenav">
<li>html</li>
<li>css</li>
<li>javascript</li>
<li>python</li>
<li>c++</li>
<li>php</li>
</ul>
</div>
</nav>
<div class="picture">
</div>
</body>
</html>
It is important that justify-content aligns the flex items in the flex-direction. so if your flex-direction is row(default), justify-content is in the row manner and if your flex-direction is column, justify-content is the vertical.
so you just need this sample:
.mobile {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}