100% height for vertical sticky menu - doesn't work - css

I'm trying to fit my sticky left menu to the height of my content, but I'm not be able to do it.
I try adding height: 100% to all parents div, but nothing happens
My code is: (before is and )
<main>
<div class="container">
<div class="content-wrapper">
<router-view />
</div>
<div class="navigation__menu">
<div
class="container-menu"
:class="{'show': this.$store.getters.showSidebar}">
<main-menu
#click.native="showNav" />
<menu-options />
</div>
</div>
</div>
</main>
<template>
<div id="main-menu">
<div class="control">
<i
class="fas fa-angle-double-right" />
</div>
</div>
</template>
<template>
<div id="menu-options">
<div
class="navigation-icons-menu">
<a
title="Home"
href="/"><i class="fas fa-home" /></a>
<a
title="FIG"
href="/fig-console"><i class="fas fa-clipboard-list" /></a>
<a
title="Service client"
href="/"><i class="fas fa-users" /></a>
<a
title="Budget"
href="/"><i class="fas fa-file-invoice" /></a>
<a
title="Contracting"
href="/"><i class="fas fa-file-contract" /></a>
<a
title="Invoicing"
href="/"><i class="fas fa-file-invoice-dollar" /></a>
<a
title="Administration"
href="/"><i class="fas fa-cogs" /></a>
</div>
<div
v-if="this.$store.getters.showSidebar"
class="navigation-links-menu">
<transition-group name="fade">
<div
v-show="this.$store.getters.showLink"
key="1">
<a
title="Home"
href="/">Home</a>
</div>
<div
v-show="this.$store.getters.showLink"
key="2">
<a
title="FIG"
href="/fig-console">FIG</a>
</div>
<div
v-show="this.$store.getters.showLink"
key="3">Service client</div>
<div
v-show="this.$store.getters.showLink"
key="4">Budget</div>
<div
v-show="this.$store.getters.showLink"
key="5">Contracting</div>
<div
v-show="this.$store.getters.showLink"
key="6">Invoicing</div>
<div
v-show="this.$store.getters.showLink"
key="7">Administration</div>
</transition-group>
</div>
</div>
</template>
.container-menu {
position: absolute;
top: 65px;
padding-top: 10px;
left: 0;
width: 62px;
min-height: 100%;
height: 100%;
background-color: $navy;
border: solid $white;
border-width: 0 1px 0 0;
z-index: 1001;
transition: all .5s ease-in-out;
.control {
display: flex;
justify-content: center;
align-items: center;
//width: 50px;
margin-bottom: 10px;
color: $white;
i {
font-size: 2rem;
cursor: pointer;
transition: all .5s ease-in-out;
}
}
&.show {
width: 170px;
.control > i {
color: $white;
transform: rotateZ(-180deg);
}
}
.navigation-icons-menu {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 50px;
float: left;
i {
color: $white;
font-size: 2rem;
padding: 10px 0;
cursor: pointer;
transition: all .5s ease-in-out;
&:hover {
color: $white;
}
}
}
.navigation-links-menu {
//padding:14px;
float: left;
color: $white;
div {
font-size: 1.35rem;
padding: 10px;
cursor: pointer;
#include breakpoint-only(tablet) {
font-size: 7px;
padding: 10px 5px;
}
a {
color: $white;
}
}
}
}

vh will solve your problem.
Instead of a pixel or percentage value. Use vh which stands for "viewport height".
An element with height: 100vh will be given a height the full height of the viewport.
.container-menu {
position: absolute;
top: 65px;
padding-top: 10px;
left: 0;
width: 62px;
height: 100vh;
background-color: $navy;
border: solid $white;
border-width: 0 1px 0 0;
z-index: 1001;
transition: all .5s ease-in-out;
.control {
display: flex;
justify-content: center;
align-items: center;
//width: 50px;
margin-bottom: 10px;
color: $white;
i {
font-size: 2rem;
cursor: pointer;
transition: all .5s ease-in-out;
}
}
&.show {
width: 170px;
.control > i {
color: $white;
transform: rotateZ(-180deg);
}
}
.navigation-icons-menu {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 50px;
float: left;
i {
color: $white;
font-size: 2rem;
padding: 10px 0;
cursor: pointer;
transition: all .5s ease-in-out;
&:hover {
color: $white;
}
}
}
.navigation-links-menu {
//padding:14px;
float: left;
color: $white;
div {
font-size: 1.35rem;
padding: 10px;
cursor: pointer;
#include breakpoint-only(tablet) {
font-size: 7px;
padding: 10px 5px;
}
a {
color: $white;
}
}
}
}

Related

How do I get the menu to have a scroll

My menu box has more content to show but i cannot scroll down to see that content , it just disappears. I have tried doing overflow-y: auto; but does not work.
Here is my code
<div class="nav-cont d-flex align-items-center justify-content-end">
<div class="col-md-3">
<div class="hamburger-menu">
<input id="menu__toggle" type="checkbox" />
<label class="menu__btn" for="menu__toggle">
<span></span>
</label>
<ul class="menu__box d-flex flex-column ">
<div class="menu-title-container d-flex align-items-center justify-content-center">
<p class="menu-title">Most Popular</p>
</div>
<div class="menu-line-break"></div>
<li><a class="menu__item" href="#">Batteries</a></li>
<li><a class="menu__item" href="#">Engine Oil</a></li>
<li><a class="menu__item" href="#">Spark Plugs</a></li>
<li><a class="menu__item" href="#">Tyres</a></li>
<li class="menu-btn-expand"><a class="menu__item" href="#">Show More</a></li>
<div class="menu-line-break"></div>
<div class="menu-title-container d-flex align-items-center justify-content-center">
<p class="menu-title">Shop Deals</p>
</div>
<div class="menu-line-break"></div>
<li><a class="menu__item" href="#">Top Deals</a></li>
<div class="menu-line-break"></div>
<div class="menu-title-container d-flex align-items-center justify-content-center">
<p class="menu-title">Shop By</p>
</div>
<div class="menu-line-break"></div>
<li><a class="menu__item" href="#">By Make</a></li>
<li><a class="menu__item" href="#">By Model</a></li>
<div class="menu-line-break"></div>
<div class="menu-title-container d-flex align-items-center justify-content-center">
<p class="menu-title">Trustworthy Advice</p>
</div>
</ul>
</div>
</div>
Here is the CSS
/*Hamburger Menu*/
#menu__toggle {
opacity: 0;
}
#menu__toggle:checked ~ .menu__btn > span {
transform: rotate(45deg);
}
#menu__toggle:checked ~ .menu__btn > span::before {
top: 0;
transform: rotate(0);
}
#menu__toggle:checked ~ .menu__btn > span::after {
top: 0;
transform: rotate(90deg);
}
#menu__toggle:checked ~ .menu__box {
visibility: visible;
left: 0;
}
.menu__btn {
display: flex;
align-items: center;
position: relative;
top: -1rem;
left: 3rem;
width: 26px;
height: 26px;
cursor: pointer;
z-index: 1;
}
.menu__btn > span,
.menu__btn > span::before,
.menu__btn > span::after {
display: block;
position: absolute;
width: 100%;
height: 5px;
background-color: #616161;
transition-duration: 0.25s;
}
.menu__btn > span::before {
content: "";
top: -8px;
}
.menu__btn > span::after {
content: "";
top: 8px;
}
.menu__box {
display: block;
position: fixed;
visibility: hidden;
left: -100%;
width: 300px;
height: 100%;
margin: 0;
padding: 1rem 0;
list-style: none;
background-color: #fff;
box-shadow: 1px 0px 6px rgba(0, 0, 0, 0.2);
border-right: 1px solid black;
border-top: 1px solid black;
overflow-y: auto;
transition-duration: 0.25s;
}
.menu__box li a {
font-size: 0.8rem;
font-family: "Poppins";
}
.menu__item {
display: block;
padding: 12px 24px;
color: #333;
font-family: "Roboto", sans-serif;
font-size: 20px;
font-weight: 600;
text-decoration: none;
border-top: none;
transition-duration: 0.25s;
}
.menu__item:hover {
background-color: #f5f5f5;
}
.menu-line-break {
background-color: #f5f5f5;
width: 80%;
height: 0.2rem;
margin: 0.5rem auto;
}
.menu-btn-expand {
text-decoration: underline;
}
.menu-title-container {
width: 100%;
}
I appreciate the help in advance. Thank you. I do not know where the problem is from , I am a bit new to this .
I removed the overflow-y: auto; and added overflow: auto; removing the hidden part from either side.
.menu__box {
display: block;
position: fixed;
visibility: hidden;
left: -100%;
width: 300px;
height: calc(100% - 100px);
margin: 0;
padding: 1rem 0;
list-style: none;
background-color: #fff;
box-shadow: 1px 0px 6px rgba(0, 0, 0, 0.2);
border-right: 1px solid black;
border-top: 1px solid black;
overflow: auto;
transition-duration: 0.25s;
}

menu disappear when hover the list item

when i hover over the hamburger icon in 1000px mode the menu appears, but when i hover over menu it disappears. i have tried z-index and tricks related to position but cannot get the solution.
the issue is in 1000px because in full screen mode i can hover over sub-menu, but not on 1000px screen.
please help, thank you.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ESPN</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./app.css">
</head>
<body>
<header class="header">
<div class="header__logo"><span>ESPN</span> / Media Distribution</div>
<div class="hamburger__icon__section">
</div>
<nav class="navbar">
<div class="navbar__items">
<div class="hamburger__icon"><div></div><div></div><div></div></div>
<ul class="navbar__lists__items">
<li class="navbar__hover__items">
Sports Programming
<ul class="navbar__lists__items__item">
<li>Boxing</li>
<li>Films</li>
<li>Fina</li>
<li>World Athletics</li>
<li>Ncaa</li>
<li>Pocker</li>
<li>Special Olympics</li>
<li>X Games</li>
</ul>
</li>
<li class="navbar__hover__items">Content Calender</li>
<li class="navbar__hover__items">
Contacts
<ul class="navbar__lists__items__item">
<li>Asia Pacific</li>
<li>Canada</li>
<li>Europe, Middle East and Africa</li>
<li>Latin America</li>
<li>Mexico</li>
</ul>
</li>
</ul>
<div class="search">
<input type="text" placeholder="Search">
<i class="fa fa-search"></i>
</input>
</div>
</div>
</nav>
</header>
<div class="video__section">
<div class="video__header__wrapper">
<video src="./6. Exercise Higher Order Functions.mp4" loop="true" autoplay="true" muted>
</video>
</div>
<div class="video__section__content">
<p><span>ESPN /</span> Media Distribution</p>
</div>
</div>
<div class="image__section">
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
</div>
<div class="copyright__section">
<div class="copyright__section__content">
<p>Copyright © 2020 ESPN, Inc. - All Rights Reserved | Terms of Use | Privacy Policy</p>
</div>
</div>
</body>
</html>
#import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght#600&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
font-family: 'Fira Sans', sans-serif;
line-height: 1.6rem;
}
body {
font-size: 1.6rem;
}
.header {
display: flex;
justify-content: space-around;
align-items: stretch;
background-color:rgb(202, 8, 19);
color: #fff;
border-bottom: 1px solid #fff;
}
.header__logo {
font-size: 20px;
line-height: 50px;
user-select: none;
}
.header__logo span {
font-style: oblique;
}
.navbar__items {
display: flex;
justify-content: center;
align-items: stretch;
}
.navbar__lists__items {
display: flex;
justify-content: center;
align-items: stretch;
list-style: none;
}
.navbar__lists__items > li {
margin: 0 5px;
}
.navbar__lists__items__item {
width: 250px;
opacity: 0;
pointer-events: none;
position: absolute;
top: 59px;
left: 0px;
right: 0;
list-style: none;
transition: all 0.3s;
}
.navbar__lists__items__item li {
cursor: pointer;
border: 1px solid #666;
background-color: #fff;
line-height: 1.6rem;
}
.navbar__lists__items__item li a:hover {
background-color: #666666;
color: #fff;
}
.navbar__lists__items__item li a {
padding: 10px 20px;
display: block;
text-decoration: none;
color: #666666;
text-transform: uppercase;
}
.navbar__hover__items {
display: flex;
justify-content: center;
align-items: stretch;
position: relative;
line-height: 50px;
z-index: 1;
}
.navbar__hover__items > a {
margin-right: 5px;
}
.navbar__lists__items .navbar__hover__items:nth-child(odd)::after {
content: ' \02C5';
}
.navbar__lists__items > li > a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
}
.navbar__hover__items:nth-child(2n+1):hover > a {
background-color: #fff;
color: rgb(202, 8, 19);
}
.navbar__hover__items:nth-child(2n+1):hover .navbar__lists__items__item {
opacity: 1;
pointer-events: all;
transform: translateY(-10px);
}
.search {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.search input {
border: 1px solid #fff;
outline: none;
border-radius: 5px;
padding: 5px;
}
.search i {
position: absolute;
color: #000;
top: 50%;
left: 95%;
transform: translate(-95%, -50%);
margin-right: -30px;
}
.video__section {
width: 100%;
height: 100%;
position: relative;
color: #fff;
font-size: 40px;
}
.video__header__wrapper {
width: 100%;
height: 100%;
}
.video__header__wrapper video {
width: 100%;
height: 100%;
}
.video__section__content {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -40%);
user-select: none;
}
.video__section__content span {
font-style: oblique;
}
.image__section {
display: flex;
justify-content: center;
flex-wrap: wrap;
align-items: center;
}
.image__section .image {
flex-basis: 25%;
overflow: hidden;
position: relative;
height: 200px;
width: 150px;
}
.image__section .image img {
width: 100%;
height: 100%;
cursor: pointer;
transform: scale(1.1);
transition: all 0.3s;
}
.overlay {
position: absolute;
right: 0;
left: 0;
bottom: 100%;
background-color: #000;
width: 100%;
overflow: hidden;
opacity: 0.7;
transition: 0.3s ease;
}
.image:hover img {
transform: scale(1);
}
.image:hover > .overlay {
height: 100%;
bottom: 0;
}
.copyright__section {
font-size: 10px;
background-color: rgb(202, 8, 19);
color: #fff;
}
.copyright__section__content {
margin-top: 0;
margin-bottom: 0;
margin-left: 30px;
}
#media (max-width: 1000px) {
.header {
padding: 0 10px;
}
.navbar__items {
position: relative;
}
.navbar__lists__items {
display: none;
position: absolute;
top: 50px;
right: 50px;
width: 300px;
padding: 0 10px;
background-color: #fff;
font-family: 'Lato',Helvetica,Arial,Lucida,sans-serif;
z-index: 1;
box-shadow: 0 0 0.5px 1px rgb(255, 255, 255, 0.7);
}
.navbar__lists__items > li > a {
color: #000;
}
.navbar__lists__items .navbar__hover__items:nth-child(odd)::after {
content: "";
display: block;
}
.navbar__hover__items {
display: block;
color: #000;
}
.navbar__lists__items__item {
display: none;
}
.video__section {
font-size: 35px;
}
.search {
height: 50px;
}
.hamburger__icon__section {
display: flex;
justify-content: flex-end;
flex: 2;
}
.hamburger__icon {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
margin-right: 10px;
cursor: pointer;
}
.hamburger__icon > div {
width: 25px;
height: 2px;
margin: 3px 0;
background-color: #fff;
}
.hamburger__icon:hover + .navbar__lists__items {
display: block;
}
}
You could handle the show/hide using javascript instead of css because the way you do it right now whenever the browser detects your cursor is no longer on top of the hamburger_buttton it will hide your menu so it would be better to handle the event with a click instead. Or you can check this answer. Hope it helps.
let navbarListItems = document.querySelector('.navbar__lists__items');
let hamburgetButton = document.querySelector('.hamburger__icon');
hamburgetButton.onclick = function () {
navbarListItems.style.display = navbarListItems.style.display === 'none' ? 'block' : 'none';
}
#import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght#600&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
font-family: 'Fira Sans', sans-serif;
line-height: 1.6rem;
}
body {
font-size: 1.6rem;
}
.header {
display: flex;
justify-content: space-around;
align-items: stretch;
background-color: rgb(202, 8, 19);
color: #fff;
border-bottom: 1px solid #fff;
}
.header__logo {
font-size: 20px;
line-height: 50px;
user-select: none;
}
.header__logo span {
font-style: oblique;
}
.navbar__items {
display: flex;
justify-content: center;
align-items: stretch;
}
.navbar__lists__items {
display: flex;
justify-content: center;
align-items: stretch;
list-style: none;
}
.navbar__lists__items>li {
margin: 0 5px;
}
.navbar__lists__items__item {
width: 250px;
opacity: 0;
pointer-events: none;
position: absolute;
top: 59px;
left: 0px;
right: 0;
list-style: none;
transition: all 0.3s;
}
.navbar__lists__items__item li {
cursor: pointer;
border: 1px solid #666;
background-color: #fff;
line-height: 1.6rem;
}
.navbar__lists__items__item li a:hover {
background-color: #666666;
color: #fff;
}
.navbar__lists__items__item li a {
padding: 10px 20px;
display: block;
text-decoration: none;
color: #666666;
text-transform: uppercase;
}
.navbar__hover__items {
display: flex;
justify-content: center;
align-items: stretch;
position: relative;
line-height: 50px;
z-index: 1;
}
.navbar__hover__items>a {
margin-right: 5px;
}
.navbar__lists__items .navbar__hover__items:nth-child(odd)::after {
content: ' \02C5';
}
.navbar__lists__items>li>a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
}
.navbar__hover__items:nth-child(2n+1):hover>a {
background-color: #fff;
color: rgb(202, 8, 19);
}
.navbar__hover__items:nth-child(2n+1):hover .navbar__lists__items__item {
opacity: 1;
pointer-events: all;
transform: translateY(-10px);
}
.search {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.search input {
border: 1px solid #fff;
outline: none;
border-radius: 5px;
padding: 5px;
}
.search i {
position: absolute;
color: #000;
top: 50%;
left: 95%;
transform: translate(-95%, -50%);
margin-right: -30px;
}
.video__section {
width: 100%;
height: 100%;
position: relative;
color: #fff;
font-size: 40px;
}
.video__header__wrapper {
width: 100%;
height: 100%;
}
.video__header__wrapper video {
width: 100%;
height: 100%;
}
.video__section__content {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -40%);
user-select: none;
}
.video__section__content span {
font-style: oblique;
}
.image__section {
display: flex;
justify-content: center;
flex-wrap: wrap;
align-items: center;
}
.image__section .image {
flex-basis: 25%;
overflow: hidden;
position: relative;
height: 200px;
width: 150px;
}
.image__section .image img {
width: 100%;
height: 100%;
cursor: pointer;
transform: scale(1.1);
transition: all 0.3s;
}
.overlay {
position: absolute;
right: 0;
left: 0;
bottom: 100%;
background-color: #000;
width: 100%;
overflow: hidden;
opacity: 0.7;
transition: 0.3s ease;
}
.image:hover img {
transform: scale(1);
}
.image:hover>.overlay {
height: 100%;
bottom: 0;
}
.copyright__section {
font-size: 10px;
background-color: rgb(202, 8, 19);
color: #fff;
}
.copyright__section__content {
margin-top: 0;
margin-bottom: 0;
margin-left: 30px;
}
#media (max-width: 1000px) {
.header {
padding: 0 10px;
}
.navbar__items {
position: relative;
}
.navbar__lists__items {
display: none;
position: absolute;
top: 50px;
right: 50px;
width: 300px;
padding: 0 10px;
background-color: #fff;
font-family: 'Lato', Helvetica, Arial, Lucida, sans-serif;
z-index: 1;
box-shadow: 0 0 0.5px 1px rgb(255, 255, 255, 0.7);
}
.navbar__lists__items>li>a {
color: #000;
}
.navbar__lists__items .navbar__hover__items:nth-child(odd)::after {
content: "";
display: block;
}
.navbar__hover__items {
display: block;
color: #000;
}
.navbar__lists__items__item {
display: none;
}
.video__section {
font-size: 35px;
}
.search {
height: 50px;
}
.hamburger__icon__section {
display: flex;
justify-content: flex-end;
flex: 2;
}
.hamburger__icon {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
margin-right: 10px;
cursor: pointer;
}
.hamburger__icon>div {
width: 25px;
height: 2px;
margin: 3px 0;
background-color: #fff;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ESPN</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./app.css">
</head>
<body>
<header class="header">
<div class="header__logo"><span>ESPN</span> / Media Distribution</div>
<div class="hamburger__icon__section">
</div>
<nav class="navbar">
<div class="navbar__items">
<div class="hamburger__icon">
<div></div>
<div></div>
<div></div>
</div>
<ul class="navbar__lists__items">
<li class="navbar__hover__items">
Sports Programming
<ul class="navbar__lists__items__item">
<li>Boxing</li>
<li>Films</li>
<li>Fina</li>
<li>World Athletics</li>
<li>Ncaa</li>
<li>Pocker</li>
<li>Special Olympics</li>
<li>X Games</li>
</ul>
</li>
<li class="navbar__hover__items">Content Calender</li>
<li class="navbar__hover__items">
Contacts
<ul class="navbar__lists__items__item">
<li>Asia Pacific</li>
<li>Canada</li>
<li>Europe, Middle East and Africa</li>
<li>Latin America</li>
<li>Mexico</li>
</ul>
</li>
</ul>
<div class="search">
<input type="text" placeholder="Search">
<i class="fa fa-search"></i>
</input>
</div>
</div>
</nav>
</header>
<div class="video__section">
<div class="video__header__wrapper">
<video src="./6. Exercise Higher Order Functions.mp4" loop="true" autoplay="true" muted>
</video>
</div>
<div class="video__section__content">
<p><span>ESPN /</span> Media Distribution</p>
</div>
</div>
<div class="image__section">
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
</div>
<div class="copyright__section">
<div class="copyright__section__content">
<p>Copyright © 2020 ESPN, Inc. - All Rights Reserved | Terms of Use | Privacy Policy</p>
</div>
</div>
</body>
</html>
Simply add this to your selector :
, .navbar__lists__items:hover
The full rule should look like this :
.hamburger__icon:hover + .navbar__lists__items, .navbar__lists__items:hover {
display: block;
}
This is happening since the scope of hover effect is only limited to the hamburger icon and as soon as the hover scope is left, the css does not execute for it so in order to stabilize the menu items I have added hover scope to that <ul> too.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
font-family: 'Fira Sans', sans-serif;
line-height: 1.6rem;
}
body {
font-size: 1.6rem;
}
.header {
display: flex;
justify-content: space-around;
align-items: stretch;
background-color:rgb(202, 8, 19);
color: #fff;
border-bottom: 1px solid #fff;
}
.header__logo {
font-size: 20px;
line-height: 50px;
user-select: none;
}
.header__logo span {
font-style: oblique;
}
.navbar__items {
display: flex;
justify-content: center;
align-items: stretch;
}
.navbar__lists__items {
display: flex;
justify-content: center;
align-items: stretch;
list-style: none;
}
.navbar__lists__items > li {
margin: 0 5px;
}
.navbar__lists__items__item {
width: 250px;
opacity: 0;
pointer-events: none;
position: absolute;
top: 59px;
left: 0px;
right: 0;
list-style: none;
transition: all 0.3s;
}
.navbar__lists__items__item li {
cursor: pointer;
border: 1px solid #666;
background-color: #fff;
line-height: 1.6rem;
}
.navbar__lists__items__item li a:hover {
background-color: #666666;
color: #fff;
}
.navbar__lists__items__item li a {
padding: 10px 20px;
display: block;
text-decoration: none;
color: #666666;
text-transform: uppercase;
}
.navbar__hover__items {
display: flex;
justify-content: center;
align-items: stretch;
position: relative;
line-height: 50px;
z-index: 1;
}
.navbar__hover__items > a {
margin-right: 5px;
}
.navbar__lists__items .navbar__hover__items:nth-child(odd)::after {
content: ' \02C5';
}
.navbar__lists__items > li > a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
}
.navbar__hover__items:nth-child(2n+1):hover > a {
background-color: #fff;
color: rgb(202, 8, 19);
}
.navbar__hover__items:nth-child(2n+1):hover .navbar__lists__items__item {
opacity: 1;
pointer-events: all;
transform: translateY(-10px);
}
.search {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.search input {
border: 1px solid #fff;
outline: none;
border-radius: 5px;
padding: 5px;
}
.search i {
position: absolute;
color: #000;
top: 50%;
left: 95%;
transform: translate(-95%, -50%);
margin-right: -30px;
}
.video__section {
width: 100%;
height: 100%;
position: relative;
color: #fff;
font-size: 40px;
}
.video__header__wrapper {
width: 100%;
height: 100%;
}
.video__header__wrapper video {
width: 100%;
height: 100%;
}
.video__section__content {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -40%);
user-select: none;
}
.video__section__content span {
font-style: oblique;
}
.image__section {
display: flex;
justify-content: center;
flex-wrap: wrap;
align-items: center;
}
.image__section .image {
flex-basis: 25%;
overflow: hidden;
position: relative;
height: 200px;
width: 150px;
}
.image__section .image img {
width: 100%;
height: 100%;
cursor: pointer;
transform: scale(1.1);
transition: all 0.3s;
}
.overlay {
position: absolute;
right: 0;
left: 0;
bottom: 100%;
background-color: #000;
width: 100%;
overflow: hidden;
opacity: 0.7;
transition: 0.3s ease;
}
.image:hover img {
transform: scale(1);
}
.image:hover > .overlay {
height: 100%;
bottom: 0;
}
.copyright__section {
font-size: 10px;
background-color: rgb(202, 8, 19);
color: #fff;
}
.copyright__section__content {
margin-top: 0;
margin-bottom: 0;
margin-left: 30px;
}
#media (max-width: 1000px) {
.header {
padding: 0 10px;
}
.navbar__items {
position: relative;
}
.navbar__lists__items {
display: none;
position: absolute;
top: 50px;
right: 50px;
width: 300px;
padding: 0 10px;
background-color: #fff;
font-family: 'Lato',Helvetica,Arial,Lucida,sans-serif;
z-index: 1;
box-shadow: 0 0 0.5px 1px rgb(255, 255, 255, 0.7);
}
.navbar__lists__items > li > a {
color: #000;
}
.navbar__lists__items .navbar__hover__items:nth-child(odd)::after {
content: "";
display: block;
}
.navbar__hover__items {
display: block;
color: #000;
}
.navbar__lists__items__item {
display: none;
}
.video__section {
font-size: 35px;
}
.search {
height: 50px;
}
.hamburger__icon__section {
display: flex;
justify-content: flex-end;
flex: 2;
}
.hamburger__icon {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
margin-right: 10px;
cursor: pointer;
}
.hamburger__icon > div {
width: 25px;
height: 2px;
margin: 3px 0;
background-color: #fff;
}
/* added another line here */
.hamburger__icon:hover + .navbar__lists__items,
.hamburger__icon + .navbar__lists__items:hover{
display: block;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ESPN</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./app.css">
</head>
<body>
<header class="header">
<div class="header__logo"><span>ESPN</span> / Media Distribution</div>
<div class="hamburger__icon__section">
</div>
<nav class="navbar">
<div class="navbar__items">
<div class="hamburger__icon"><div></div><div></div><div></div></div>
<ul class="navbar__lists__items">
<li class="navbar__hover__items">
Sports Programming
<ul class="navbar__lists__items__item">
<li>Boxing</li>
<li>Films</li>
<li>Fina</li>
<li>World Athletics</li>
<li>Ncaa</li>
<li>Pocker</li>
<li>Special Olympics</li>
<li>X Games</li>
</ul>
</li>
<li class="navbar__hover__items">Content Calender</li>
<li class="navbar__hover__items">
Contacts
<ul class="navbar__lists__items__item">
<li>Asia Pacific</li>
<li>Canada</li>
<li>Europe, Middle East and Africa</li>
<li>Latin America</li>
<li>Mexico</li>
</ul>
</li>
</ul>
<div class="search">
<input type="text" placeholder="Search">
<i class="fa fa-search"></i>
</input>
</div>
</div>
</nav>
</header>
<div class="video__section">
<div class="video__header__wrapper">
<video src="./6. Exercise Higher Order Functions.mp4" loop="true" autoplay="true" muted>
</video>
</div>
<div class="video__section__content">
<p><span>ESPN /</span> Media Distribution</p>
</div>
</div>
<div class="image__section">
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
<div class="image">
<img src="./food.png" alt="">
<div class="overlay"></div>
</div>
</div>
<div class="copyright__section">
<div class="copyright__section__content">
<p>Copyright © 2020 ESPN, Inc. - All Rights Reserved | Terms of Use | Privacy Policy</p>
</div>
</div>
</body>
</html>

Stepper progress bar - responsive css

I would like to do a responsive stepper where in the lines in between steppers are connected to each step. Currently only workable with 4 steps, it becomes not responsive once it is more or less than 4 steps.
Here is the jsfiddle, currently workable with 4 steps.
.bullet.completed::after {
content: '';
position: absolute;
bottom: 10px;
height: 1px;
width: calc(133% - 21px);
background-color: #000;
margin-left: 7px;
}
I tried to change this part but it doesn't seem to work. Thanks for advance!
#stepProgressBar {
display: flex;
justify-content: space-between;
align-items: flex-end;
width: 90%;
margin: 0 auto;
margin-bottom: 40px;
}
.step {
text-align: center;
width: 20%;
position: relative;
}
.step-text {
margin-bottom: 10px;
color: #000;
}
.bullet {
border: 1px solid #000;
height: 20px;
width: 20px;
color: #000;
display: inline-block;
transition: background-color 500ms;
line-height: 20px;
}
.bullet.completed {
color: white;
background-color: #000;
}
.bullet.completed::after {
content: '';
position: absolute;
bottom: 10px;
height: 1px;
width: calc(133% - 21px);
background-color: #000;
margin-left: 7px;
}
/* Base styles and helper stuff */
.hidden {
display: none;
}
button {
padding: 5px 10px;
border: 1px solid black;
transition: 250ms background-color;
}
button:hover {
cursor: pointer;
background-color: black;
color: white;
}
button:disabled:hover {
opacity: 0.6;
cursor: not-allowed;
}
.text-center {
text-align: center;
}
.container {
max-width: 100%;
margin: 0 auto;
margin-top: 20px;
padding: 40px;
}
<div class="container">
<div id="stepProgressBar">
<div class="step">
<p class="step-text">Super Duper Long Title</p>
<div class="bullet completed">1</div>
</div>
<div class="step">
<p class="step-text">Long Long Title</p>
<div class="bullet completed">2</div>
</div>
<div class="step">
<p class="step-text">Loooong Title</p>
<div class="bullet completed">3</div>
</div>
<div class="step">
<p class="step-text">Loooong Title</p>
<div class="bullet">4</div>
</div>
</div>
</div>
Modify your .bullet.completed::after to display:flex, and set its width to 100% minus a modified margin-left value, which is equal to the width of the .bullet (20px):
.bullet.completed::after {
content: '';
position: absolute;
bottom: 10px;
height: 1px;
display:flex; /* Added */
width:calc(100% - 20px); /* Modified */
background-color: #000;
margin-left: 20px; /* Modified */
}
Here it is with seven steps:
const previousBtn = document.getElementById('previousBtn');
const nextBtn = document.getElementById('nextBtn');
const finishBtn = document.getElementById('finishBtn');
const content = document.getElementById('content');
const bullets = [...document.querySelectorAll('.bullet')];
const MAX_STEPS = 7;
let currentStep = 1;
nextBtn.addEventListener('click', () => {
bullets[currentStep - 1].classList.add('completed');
currentStep += 1;
previousBtn.disabled = false;
if (currentStep === MAX_STEPS) {
nextBtn.disabled = true;
finishBtn.disabled = false;
}
content.innerText = `Step Number ${currentStep}`;
});
previousBtn.addEventListener('click', () => {
bullets[currentStep - 2].classList.remove('completed');
currentStep -= 1;
nextBtn.disabled = false;
finishBtn.disabled = true;
if (currentStep === 1) {
previousBtn.disabled = true;
}
content.innerText = `Step Number ${currentStep}`;
});
finishBtn.addEventListener('click', () => {
location.reload();
});
#stepProgressBar {
display: flex;
justify-content: space-between;
align-items: flex-end;
width: 90%;
margin: 0 auto;
margin-bottom: 40px;
}
.step {
text-align: center;
width: 20%;
position: relative;
}
.step-text {
margin-bottom: 10px;
color: #000;
}
.bullet {
border: 1px solid #000;
height: 20px;
width: 20px;
color: #000;
display: inline-block;
transition: background-color 500ms;
line-height: 20px;
}
.bullet.completed {
color: white;
background-color: #000;
}
.bullet.completed::after {
content: '';
position: absolute;
bottom: 10px;
height: 1px;
width:calc(100% - 20px);
display:flex;
background-color: #000;
margin-left: 20px;
}
/* Base styles and helper stuff */
.hidden {
display: none;
}
button {
padding: 5px 10px;
border: 1px solid black;
transition: 250ms background-color;
}
button:hover {
cursor: pointer;
background-color: black;
color: white;
}
button:disabled:hover {
opacity: 0.6;
cursor: not-allowed;
}
.text-center {
text-align: center;
}
.container {
max-width: 100%;
margin: 0 auto;
margin-top: 20px;
padding: 40px;
}
<div class="container">
<div id="stepProgressBar">
<div class="step">
<p class="step-text">Super Duper Long Title</p>
<div class="bullet">1</div>
</div>
<div class="step">
<p class="step-text">Long Long Title</p>
<div class="bullet">2</div>
</div>
<div class="step">
<p class="step-text">Loooong Title</p>
<div class="bullet">3</div>
</div>
<div class="step">
<p class="step-text">Title</p>
<div class="bullet ">4</div>
</div>
<div class="step">
<p class="step-text">Title</p>
<div class="bullet ">5</div>
</div>
<div class="step">
<p class="step-text">Title</p>
<div class="bullet ">6</div>
</div>
<div class="step">
<p class="step-text">Title</p>
<div class="bullet ">7</div>
</div>
</div>
<div id="main">
<p id="content" class="text-center">Step Number 1</p>
<button id="previousBtn" class="hidden"></button>
<button id="nextBtn">Next</button>
<button id="finishBtn" class="hidden">Finish</button>
</div>
</div>

can't vertical align content within a row [duplicate]

This question already has answers here:
Bootstrap Vertical Center contents in row
(2 answers)
Closed 4 years ago.
I'm going crazy being unable to align some elements to the centre of a Bootstrap row. The only thing that seems to work is positioning some elements as absolute relative to the row, but I would like to avoid this as it would be an issue adjusting the horizontal gaps between objects when it comes to responsiveness.
Could you advice a more efficient way to vertically align all the content within the following row element? My code below:
PS. I'm using bootstrap 3.0 and SCSS
HTML
<div class="standard-container">
<div class="row title-menu-row">
<div class="col-md-4 title-menu-col">
<h1>Your predictions</h1>
</div>
<div class="col-md-7 title-menu-col">
<span class="badge badge-error pmd-ripple-effect">12</span>
<span>Not predicted yet</span>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch">
<label class="onoffswitch-label" for="myonoffswitch"></label>
</div>
</div>
<div class="col-md-1 title-menu-col icons">
<a href="#">
<span class="fa-layers fa-fw" style="">
<i class="fal fa-female" data-fa-transform="shrink-3 up-1 left-6"></i>
<i class="fal fa-male" data-fa-transform="shrink-3 down-1"></i>
</span>
</a>
<a href="#">
<i class="fal fa-table"></i>
</a>
</div>
</div>
SCSS
// --------------- Toggle switch ---------------
.onoffswitch {
position: relative; width: 48px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
height: 24px; padding: 0; line-height: 24px;
border: 2px solid #F1F1F5; border-radius: 24px;
background-color: #F1F1F5;
transition: background-color 0.3s ease-in;
}
.onoffswitch-label:before {
content: "";
display: block; width: 24px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 22px;
border: 2px solid #F1F1F5; border-radius: 24px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label {
background-color: #2DC76D;
}
.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before {
border-color: #2DC76D;
}
.onoffswitch-checkbox:checked + .onoffswitch-label:before {
right: 0px;
}
//---------------all else -----------------
.standard-container {
padding: 0;
margin: 170px 0 0 155px;
.title-menu-row, .title-menu-col {
margin: 0;
padding: 0;
border: 1px solid red;
}
h1 {
color: rgba(117, 64, 238, 1);
margin: 0;
}
}
.title-menu-row {
margin-bottom: 100px !important;
vertical-align: top;
.title-menu-col {
}
.onoffswitch {
display: inline-block;
.onoffswitch-label {
margin: 0;
}
}
.icons {
}
.icon > a, .icons > a {
color: rgba(117, 64, 238, 1);
font-size: 20px;
}
.icon:first-child > a {
margin-right: 200px;
}
}
Here's a CodePen illustrating the issue.
https://codepen.io/alopez25/live/PRNayZ
Try -
display: flex;
align-items:center;
Here jsfiddle -
https://jsfiddle.net/5v35gvr7/1/
<div class="wrap">
<div class="inner-wrap">Hello</div>
<div class="inner-wrap">Hello</div>
</div>
.wrap{
height: 30px;
background: green;
display: flex;
align-items: center;
}
.inner-wrap{
margin: 0px 10px;
background: blue;
display: inline-block;
}
Created a sample fiddle from your code
Added a small css change
.container{
display: flex;
align-items: center;
width: 500px;
height: 100px;
border: 1px solid #888;
justify-content: center; //remove horizontal align by removing this
}
.onoffswitch {
position: relative; width: 48px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
height: 24px; padding: 0; line-height: 24px;
border: 2px solid #F1F1F5; border-radius: 24px;
background-color: #F1F1F5;
transition: background-color 0.3s ease-in;
}
.onoffswitch-label:before {
content: "";
display: block; width: 24px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 22px;
border: 2px solid #F1F1F5; border-radius: 24px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label {
background-color: #2DC76D;
}
.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before {
border-color: #2DC76D;
}
.onoffswitch-checkbox:checked + .onoffswitch-label:before {
right: 0px;
}
.container{
display: flex;
align-items: center;
width: 500px;
height: 100px;
border: 1px solid #888;
justify-content: center;
}
.container>*{
margin: 0px 3px;
}
<div class="container">
<span class="badge badge-error pmd-ripple-effect">12</span>
<span>Not predicted yet</span>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch">
<label class="onoffswitch-label" for="myonoffswitch"></label>
</div>
</div>
Edit the Fiddle here

Show element B on hover of element A

I'm trying to show element B (share) when hovering element A (project-footer). Any ideas?
body {
margin: 0px;
}
.main-wrapper {
max-width: 400px;
height: 100%;
margin: 0px auto;
}
.project-wrapper {
display: flex;
flex-direction: column;
height: 320px;
margin-top: 100px;
}
.project-header {
display: flex;
flex-direction: row;
height: 40px;
width: 100%
}
.column {
display: flex;
flex-direction: column;
width: 50%;
}
.title {
width: 100px;
height: 18px;
border-radius: 3px;
background-color: #533C86;
}
.owner {
width: 85px;
height: 14px;
border-radius: 3px;
background-color: #533C86;
margin-top: 8px;
}
.more {
height: 40px;
width: 40px;
background-color: #F4F4F4;
margin-left: auto;
border-radius: 100px;
}
.project-body {
width: 400px;
height: 265px;
background-color: #47C7C3;
border-radius: 3px;
margin-top: 10px;
display: inherit;
}
.project-footer {
width: 400px;
height: 60px;
background-color: #31A8A4;
margin-top: auto;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
display: inherit;
flex-direction: row;
transition: background-color 0.2s ease-out, padding 0.1s ease-out;
opacity: 1;
}
.project-footer:hover {
cursor: pointer;
background-color: #B5B5B5;
padding: 30px;
}
.share {
height: 40px;
width: 40px;
background-color: #F4F4F4;
margin-bottom: 10px;
margin-top: 10px;
border-radius: 100px;
margin-right: 10px;
margin-left: auto;
transition: width 0.1s ease-out, opacity 0.1s linear;
}
.share:hover {
width: 100px;
}
<body>
<div class="main-wrapper">
<div class="project-wrapper">
<div class="project-header">
<div class="column">
<div class="title"></div>
<div class="owner"></div>
</div>
<div class="column">
<div class="more icon"></div>
</div>
</div>
<div class="project-body">
<div class="badges">
<div class="badgde"></div>
<div class="badgde"></div>
</div>
<div class="project-footer">
<div class="column">
<div class="user"></div>
<div class="user"></div>
<div class="user"></div>
</div>
<div class="column">
<div class="share icon"></div>
</div>
</div>
</div>
</div>
</div>
</body>
http://jsfiddle.net/lombi/xx8n8dux/
try to add this jQuery, use mouseover and mouseout.
<script>
$(document).ready(function(e){
$(".project-footer").mouseover(function(){
$(".share").width(100);
});
$(".project-footer").mouseout(function(){
$(".share").width(40);
});
});
</script>
use the display property
.share{
display:none;
}
.project-footer:hover .share{
display:block;
}

Resources