notification dropdown placement to button - css

I have made this concept: https://codepen.io/andrelange91/pen/yLpJRRw?editors=1100
In it, I have a bell icon which when pressed shows a dropdown with notifications.
But, depending on the screensize its never really placed with the arrow on the dropdown pointing at the middle of the bell icon..
How can i accomplish this?
I'm a bit rusty when it comes to frontend programming, and I haven't been able to find any suitable solutions when researching it.
HTML
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Much longer nav link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item notification-wrapper">
<button class="notification-button">
<i class="fas fa-bell"></i>
<span>6</span>
</button>
<div class="notification-popup">
<div class="notification-popup__header">
<h3>Notifikationer</h3>
<button title="marker alle som læst"><i class="fa-solid fa-check"></i></button>
</div>
<div class="notification-item">
<ul>
<li><i class='far fa-newspaper'></i></li>
<li>
<h2>Ny side oprettet</h2>
<p>Tjek den ud her!</p>
Nyhed til notification
</li>
<li>
<button class="" title="Makér denne som læst">
<span><i class="fas fa-check-circle"></i></span>
</button>
</li>
</ul>
</div>
<div class="notification-item">
<ul>
<li><i class='far fa-newspaper'></i></li>
<li>
<h2>Ny side oprettet</h2>
<p>Tjek den ud her!</p>
Nyhed til notification
</li>
<li>
<button class="" title="Makér denne som læst">
<span><i class="fas fa-check-circle"></i></span>
</button>
</li>
</ul>
</div>
<div class="notification-item">
<ul>
<li><i class='far fa-newspaper'></i></li>
<li>
<h2>Ny side oprettet</h2>
<p>Tjek den ud her!</p>
Nyhed til notification
</li>
<li>
<button class="" title="Makér denne som læst">
<span><i class="fas fa-check-circle"></i></span>
</button>
</li>
</ul>
</div>
<div class="notification-item">
<ul>
<li><i class='far fa-newspaper'></i></li>
<li>
<h2>Ny side oprettet</h2>
<p>Tjek den ud her!</p>
Nyhed til notification
</li>
<li>
<button class="" title="Makér denne som læst">
<span><i class="fas fa-check-circle"></i></span>
</button>
</li>
</ul>
</div>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
<nav>
</nav>
Styling
$clr-white-1: #ecf0f1;
$clr-white-2: darken($clr-white-1, 5%);
$clr-t300: #444;
$clr-t500: #95a5a6;
$clr-p300: #111;
$clr-a300: #e74c3c; //#FF6A6A; //salmon
$container-shadow: 0.5rem 0.5rem 2rem 0 rgba(black, 0.2);
$h-gutter: 2rem;
$v-gutter: 0.75rem;
body {
padding: 5% 0;
margin: 0 0 50px 0;
box-sizing: border-box;
width: 100vw;
height: 100vh;
background: $clr-white-1;
background: linear-gradient(30deg, $clr-white-2, $clr-white-1);
font-family: "Lato", Arial, sans-serif;
font-weight: 500;
letter-spacing: 0.05rem;
nav {
position: absolute;
left: 500px;
}
}
.notification-wrapper {
position: relative;
}
button.notification-button {
position: relative;
margin-right: 1em;
border-radius: 5px;
background: none;
border: none;
i {
margin: 0.5rem;
}
&:nth-of-type(1) {
i {
background: -webkit-linear-gradient(300deg, #acccea, #6495ed);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
&:nth-of-type(2) i {
background: -webkit-linear-gradient(300deg, #fff9ab, #00b8ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
svg,
.fa-bell {
color: white;
font-size: 28px;
}
span {
position: absolute;
user-select: none;
cursor: default;
font-size: 0.6rem;
background: $clr-a300;
width: 1.2rem;
height: 1.2rem;
color: $clr-white-1;
display: inline-flex;
justify-content: center;
align-items: center;
border-radius: 50%;
top: -0.33rem;
right: 0;
box-sizing: border-box;
animation-name: scaleCount;
animation-iteration-count: 1;
animation-timing-function: all;
animation-duration: 1s;
animation-delay: 0s;
#keyframes scaleCount {
0% {
transform: scale(0);
}
40% {
transform: scale(1);
}
60% {
transform: scale(0.5);
}
80% {
transform: scale(1.25);
}
}
}
}
.notification-popup {
display: none;
&.active {
display: block;
}
&:before {
// triangle
content: "";
position: absolute;
top: 1px;
right: 0;
width: 0;
height: 0;
transform: translate(-1rem, -100%);
border-left: 0.75rem solid transparent;
border-right: 0.75rem solid transparent;
border-bottom: 0.75rem solid white;
}
cursor: default;
position: absolute;
z-index: 999;
top: 56px;
left: -210px;
width: 400px;
font-weight: 300;
background: white;
border-radius: 0.5rem;
box-sizing: border-box;
box-shadow: $container-shadow;
animation-name: dropPanel;
animation-iteration-count: 1;
animation-timing-function: all;
animation-duration: 0.75s;
&__header {
h3 {
text-transform: uppercase;
font-size: 75%;
font-weight: 700;
color: #84929f;
padding: $v-gutter * 2 $h-gutter;
display: inline-block;
}
button {
float: right;
border: none;
background: none;
i {
text-transform: uppercase;
font-size: 22px;
font-weight: 700;
padding: $v-gutter * 2 $h-gutter;
color: #84929f;
}
}
}
.notification-item {
border-bottom: 2px solid lightgrey;
display: block;
overflow: hidden;
width: 100%;
padding: 10px 0;
ul {
li {
float: left;
list-style: none;
padding: 5px;
position: relative;
&:first-child {
i {
font-size: 22px;
}
}
&:last-child {
right: $h-gutter;
margin-left: $v-gutter;
float: right;
}
button {
&:hover {
opacity: 0.8;
cursor: pointer;
}
span {
color: #b5c4d2;
font-size: 140%;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
position: absolute;
}
background: none;
border: none;
}
}
}
}
}
#keyframes dropPanel {
0% {
opacity: 0;
transform: translateY(-100px) scaleY(0.5);
}
}
And for completeness sake my js
$(".notification-button").on("click", function () {
const ele = $(".notification-popup");
if (ele.hasClass("active")) {
console.log("remove active");
ele.removeClass("active");
} else {
console.log("add active");
ele.addClass("active");
}
});
document.addEventListener(
"click",
function (event) {
// If user either clicks X button OR clicks outside the modal window, then close modal by calling closeModal()
if (
event.target.closest(".notification-button") == null &&
event.target.closest(".notification-popup") == null
) {
console.log("remove active click outside");
$(".notification-popup").removeClass("active");
}
},
false
);

Don't position the popup with a negative left value, but use right: 50%; instead. That gets you the right corner aligned to the middle of the li that contains the button.
And then add transform: translateX(20px); to compensate for about half of the button width. Or use translateX(1.25em) if you want to keep it dynamic regarding font size.

Try using .notification-popup{ transform: center top; }

Related

Keep DropDown Caret animation on items hover

I have a BS4 dropdown element and I am animating the little caret on the right side of the toggle. This works wonderful so far, but only as long as the mouse is hovering the dropdown item. When I hover over the submenu items the caret rotates back. This should not happen until the mouse leaves dropdown AND dropdown-menu.
html {
font-family: Arial;
font-size: 1.4rem;
line-height: 1.4rem;
}
.dropdown {
display: inline-block;
padding: 0 7px;
}
.dropdown.show {
background-color: rgba(255, 255, 255, 0.9);
}
.dropdown a::before {
content: "";
}
.dropdown a.dropdown-toggle {
cursor: pointer;
padding: 3px 7px;
}
.dropdown a.dropdown-toggle::after {
font-size: 1.4rem;
content: ">";
color: Orange;
line-height: 1.4rem;
border-top: 0;
border-right: 0;
border-bottom: 0;
border-left: 0;
vertical-align: middle;
transition: 0.5s;
}
.dropdown a.dropdown-toggle:hover::after {
transform: rotate(90deg);
}
.dropdown .dropdown-menu {
min-width: initial;
padding: 0.5rem;
margin: 0;
margin-left: 7px;
font-size: initial;
border-radius: 0;
transition: all 0.5s;
overflow: hidden;
transform-origin: top center;
transform: scale(1,0);
display: block;
border: none;
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
}
a.dropdown-item {
font-size: 1.6rem;
line-height: 2.9rem;
text-decoration: none;
}
a.dropdown-item:hover {
color: Orange;
}
.dropdown:hover .dropdown-toggle {
background-color: rgba(255, 255, 255, 0.9);
}
.dropdown:hover .dropdown-menu {
transform: scale(1);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js"></script>
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">
MAIN
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Sub1</a><br/>
<a class="dropdown-item" href="#">Sub2</a><br/>
<a class="dropdown-item" href="#">Sub3</a>
</div>
</div>
As the animated rotate in this included snippet does not work for unknown reason I have prepared a Codepen as well. Here you can see the rotation:
https://codepen.io/SchweizerSchoggi/pen/GRoZYqV
My wish is to keep the rotated caret as long as the mouse position is over dropdown or the dropdown-menu.
Since with css you can't go back to "previous siblings" (let alone parent) elements, you can position the dropdown-toggle element after the menu like this:
<div class="dropdown">
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Sub1</a>
<a class="dropdown-item" href="#">Sub2</a>
<a class="dropdown-item" href="#">Sub3</a>
</div>
<a class="dropdown-toggle" data-toggle="dropdown">MAIN</a>
</div>
so that on hover of the menu the dropdown-toggle element can be reached like this:
.dropdown-menu:hover + a:after{
transform: rotate(90deg);
}
Here is the working fiddle.

Css transition not working on ul element of navbar

I am trying to animate slider up and down on toggle on navbar using javascript but the css transition property is not working on the ul element
Following is my updated codepen https://codepen.io/divya95/pen/vYNdKrz
Code:
<div class="container row">
<nav class="nav">
<a class="logo"><img src="../flexbox/vanderbilt-commodores-1.svg"></a>
<ul class="nav__list nav__list--primary">
<li class="nav__item">
Home
</li>
<li class="nav__item">
About
</li>
<li class="nav__item">
Contact Us
</li>
<li class="nav__item">
Sign In
</li>
<li class="nav__item">
Sign Up
</li>
</ul>
<button class="nav-toggle">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</button>
<!-- <ul class="nav__list nav__list--secondary">
</ul> -->
</nav>
</div>
Css:
.nav-visible {
width: 100%;
text-align: center;
position: fixed;
display: flex;
flex-direction: column;
justify-content: center;
top: 40px;
display: block;
background: #2E323F;
list-style-type: none;
padding: 1em;
/* this is not working */
transition: height 5s ease;
}
Here I used jQuery because it's easier for me but you can make it without it.
notice how i also changed .nav-visible and .nav__list
$(document).ready(function(){
$('.nav-toggle').click(function () {
$(this).toggleClass('is-active');
toggleMenu($(this).hasClass('is-active'));
});
});
function toggleMenu(openMenu) {
let menu = $('.nav__list');
if(openMenu) {
menu.css('height', 'auto');
let nextHeight = menu.height();
menu.css('height', 0);
menu.animate({
'height': nextHeight,
'padding': '1em'
}, 200, function() {
menu.css({
'height': 'auto',
});
});
} else {
menu.css('overflow', 'hidden');
menu.animate({
'height': 0,
'padding': 0
}, 200);
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Montserrat', sans-serif;
font-size: 1.3125rem;
line-height: 1.6;
color: #222C2A;
}
.container {
max-width: 1200px;
}
.row {
display: flex;
justify-content: space-between;
}
.nav {
display: flex;
justify-content: space-between;
width: 100%;
background: #2E323F;
}
.nav__list {
height: 0;
overflow: hidden;
}
.nav__link {
text-decoration: none;
text-transform: uppercase;
font-size: 1rem;
font-weight: 600;
color: white;
}
.nav__list {
width: 100%;
text-align: center;
position: fixed;
display: flex;
flex-direction: column;
justify-content: center;
top: 40px;
display: block;
background: #2E323F;
list-style-type: none;
padding: 0em;
}
.nav-visible {
padding: 1em;
}
.nav-visible .nav__item {
padding-bottom: 1em;
}
.nav__link {
padding: 1em;
}
.logo {
margin-left: 2.5em;
}
.logo img {
width: 45px;
height: 45px;
margin-left: 1em;
margin-top: 0.5em;
margin-right: 0.5em;
}
.nav-toggle {
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
margin-top: 0.85em;
margin-right: 0.95em;
}
.bar {
cursor: pointer;
display: block;
height: 2px;
background: #222C2A;
transition: all 0.3s ease-in-out;
}
.bar:nth-child(1) {
-webkit-transform: translateY(-6px);
transform: translateY(-6px);
}
.bar:nth-child(3) {
-webkit-transform: translateY(6px);
transform: translateY(6px);
}
.hamburger-active .bar:nth-child(1) {
-webkit-transform: translateY(2px) rotate(45deg);
transform: translateY(2px) rotate(45deg);
}
.hamburger-active .bar:nth-child(2) {
opacity: 0;
}
.hamburger-active .bar:nth-child(3) {
-webkit-transform: translateY(-2px) rotate(-45deg);
transform: translateY(-2px) rotate(-45deg);
}
#media(min-width: 700px) {
header {
background: #2E323F;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
}
.nav {
display: flex;
justify-content: space-between;
}
.nav__list {
list-style-type: none;
display: flex;
/* visibility: visible; */
}
.nav__link {
text-decoration: none;
text-transform: uppercase;
font-size: 0.85rem;
margin-right: 0.8em;
}
.nav-toggle {
display: none;
}
.nav__item {
margin-right: 1.5em;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
<div class="container row">
<nav class="nav">
<a class="logo"><img src="../flexbox/vanderbilt-commodores-1.svg"></a>
<ul class="nav__list nav__list--primary">
<li class="nav__item">
Home
</li>
<li class="nav__item">
About
</li>
<li class="nav__item">
Contact Us
</li>
<li class="nav__item">
Sign In
</li>
<li class="nav__item">
Sign Up
</li>
</ul>
<button class="nav-toggle">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</button>
</nav>
</div>
</header>

How to move navlinks down the page

Every time I try to move the navlinks/navbar down by about 25px, the clickable link stays at the top however the text appears where I move it to therefore the navlinks are no longer clickable.
How can I move the navbar down and ensure that the actual text is clickable?
Note: I've tried using margin and padding so many times. The links aren't clickable at all when I use margin.
UPDATE:The issue is related to the animated background because when I removed the background, the navbar worked fine. I've updated my post with the code for the background.
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
background-color: black;
color: white;
font-size: 20px;
}
.navbar-links ul {
margin: 0;
padding: 0;
display: flex;
}
.navbar-links li {
list-style: none;
}
.navbar-links li a {
text-decoration: none;
color: white;
padding-left: 1rem;
padding-right: 1em;
padding-top: 1em;
display: block;
}
.navbar-links li:hover {
background: #555;
}
.animation-area {
background: rgb(22,168,194);
background: linear-gradient(0deg, rgba(22,168,194,1) 0%, rgba(27,28,28,1)
100%);
width: 100%;
height: 100vh;
}
.box-area{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 97%;
overflow: hidden;
}
.box-area .box-item{
position: absolute;
display: block;
list-style: none;
width: 25px;
height: 25px;
background: rgba(255, 255, 255, 0.2);
animation: animatedSquares 20s linear infinite;
bottom: -150px;
}
.box-area .box-item:nth-child(1){
left: 86%;
width: 80px;
height: 80px;
animation-delay: 0s
}
.box-area .box-item:nth-child(2){
left: 12%;
width: 30px;
height: 30px;
animation-delay: 1.5s;
animation-duration: 10s;
}
.box-area .box-item:nth-child(3){
left: 70%;
width: 100px;
height: 100px;
animation-duration: 5.5s;
}
#keyframes animatedSquares{
0%{
transform: translateY(0) rotate(0deg);
opacity: 1;
}
100%{
transform: translateY(-800px) rotate(360deg);
opacity: 0;
}
}
<div class="banner-text">
<nav class="navbar">
<a href="#" class="toggle-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</a>
<div class="navbar-links">
<ul>
<li><a class="navlink" href="#">Page 1</a></li>
<li><a class="navlink" href="#">Page 2</a></li>
<li><a class="navlink" href="#">Page 3</a></li>
<li><a class="navlink" href="#">Page 4</a></li>
</ul>
</div>
</nav>
</div>
<div class="animation-area">
<ul class="box-area">
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
</ul>
</div>
Try this
.navbar-links li {
list-style: none;
margin-top: 1rem;
}
.navbar-links li a {
text-decoration: none;
color: white;
padding: .363rem;
display: block;
}
I've solved the issue! I have an animated background on the home screen and the background had position:absolute; which conflicted with the navbar. I just removed position: absolute; from the background and styled it differently.

Bootrap 4 collapse not collapsing/disappearing on page scroll on IOS Safari

The navbar-collapse collapses/disappears when clicking a menu link to an actual "page" but it doesn't collapse/disappear when clicking a "custom" menu link to scroll to a different section on the same page.
I have the navbar-collapse appearing as a full screen when toggling the Hamburger Icon. The JQuery fixes this but it still doesn't work on IOS Safari.
HERE IS MY CSS
* { cursor: pointer; }
#site-header{
height: 85px;
top: 0;
z-index: 3000;
}
.logged-in #site-header{
top: 32px;
}
#primary {
margin-top: 85px;
}
.nav {
display: block;
}
.navbar {
height: 75px;
width: 100%;
padding: 0;
background: black;
}
.navbar-nav {
float: none!important;
}
.navbar-collapse {
position: absolute;
background: black;
width: 100%;
padding-right: 30px;
padding-top: 0px;
padding-bottom: 35px;
border: 0px;
margin-top: 0px;
height: 110vh;
left: 0;
top:0;
background-size: cover;
}
.navbar-image {
position: absolute;
opacity: .2;
right: 0px;
top:0%;
margin-top: -15px;
padding-left: 30px;
padding-right: 30px;
bottom: 0;
margin: auto;
z-index: 1;
}
.navbar-image:hover, .navbar-image:active {
-webkit-transition-duration: 5.8s;
-moz-transition-duration: 5.8s;
-o-transition-duration: 5.8s;
transition-duration: 5.8s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
overflow:hidden;
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
}
.collapsing {
position: relative;
height: 0;
overflow: hidden;
-webkit-transition: height .01s;
-moz-transition: height .01s;
-ms-transition: height .01s;
-o-transition: height .01s;
transition: height .01s;
}
.navbar-collapse ul {
position: absolute;
margin-left: 50px;
margin-top: 80px;
z-index: 2;
}
.navbar-collapse ul li {
margin-bottom: 10px;
text-transform: uppercase;
letter-spacing: 1px;
}
.navbar-collapse ul li a{
color: white!important;
font-family: 'Montserrat', sans-serif;
font-style: normal;
font-weight: 300;
}
HERE IS THE HTML
<header id="site-header" class="container-fluid">
<nav class="navbar fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggler disable" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="icon-bar top-menu"></span>
<span class="icon-bar mid-menu"></span>
<span class="icon-bar bottom-menu"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav">
<li class="menu-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="menu-item">
<a class="nav-link" href="#">Somthing Else</a>
</li>
</ul>
</div>
</div>
</nav>
JQUERY
(function ($) {
$(document).ready(function () {
$(".navbar-collapse ul li a").on("click", function () {
$(".navbar-collapse").collapse("hide");
});
});
})(jQuery);

Selectors fail to translate properly from Chrome to Firefox and Safari

Unabridged Explanation
Last night I was working on replicating an interesting Codepen I found. After I finished it, I was extremely happy with how it worked. Since I wasn't planning on using it in production, I neglected to use the proper CSS prefixes to insure cross-browser compatibility. However, when I decided to check it in Safari and Firefox I noticed that my ":hover" events weren't translating properly, and so far I have been unable to fix it. I do not need this project for anything, but I would like some help figuring out why this is occurring so I can be prepared to address this issue in future developments.
Direct Problem
In Firefox and Safari, when you mouse over the menu items that are to the right of the "Fly-Out" menu headers they collapse, whereas in Chrome they remain out.
I would like to stress that I understand why certain features like the transitions aren't working, as I didn't specify the "webkit" or "moz" prefix for most of them. It is simply the collapsing menu that's troubling me.
Code
ul.sidebar {
display: block;
position: absolute;
margin: 0;
left: 0;
height: 100%;
width: 6.5em;
background: #aa2266;
padding: 0;
text-align: center;
}
ul.sidebar * {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
ul.sidebar a {
color: white;
text-decoration: none;
margin: 0;
display: inline-block;
width: 100%;
height: 100%;
}
ul.sidebar a > i {
margin-top: 0.13333em;
font-size: 2em;
display: block;
margin-bottom: 0.2em;
}
ul.sidebar a > span {
font-size: 0.8em;
font-family: sans-serif;
}
ul.sidebar li {
transition: background 0.3s;
background: #aa2266;
}
ul.sidebar > li {
margin: 0;
padding: 0;
height: 4em;
display: inline-block;
position: relative;
width: 100%;
background: #aa2266;
transition: background 0.3s;
}
ul.sidebar > li:hover {
background: #dc3278;
}
ul.sidebar > li:hover:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 100%;
width: 6px;
background: linear-gradient(to right, rgba(0, 0, 0, 0.25) 0%, transparent 100%);
}
ul.sidebar > li > a {
transition: background 0.3s;
}
ul.sidebar > li > a:hover {
background: #ff5f87;
}
ul.sidebar > li > ul {
overflow: hidden;
height: 4em;
padding: 0;
position: absolute;
z-index: -1;
margin: 0;
color: red;
left: 100%;
transition-delay: 0.3s;
transition-property: transform;
transition-duration: 0.6s;
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
width: auto;
list-style: none;
white-space: nowrap;
top: 0;
background: #dc3278;
}
ul.sidebar > li > ul > li {
overflow: hidden;
background: none;
margin: 0 0px 0 -4px;
padding: 0;
display: inline-block;
width: 6.5em;
height: 4em;
transition: background 0.3s;
}
ul.sidebar > li > ul > li:hover {
background: #fa648c;
}
ul.sidebar li:hover > ul {
-webkit-transform: translateX(0);
transform: translateX(0);
}
ul.sidebar li:hover > ul > li {
color: white;
}
body {
padding: 0;
position: fixed;
margin: 0;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #450f30;
}
description {
position: absolute;
bottom: 0;
right: 0;
padding: 0 0.4em 1em 0;
color: white;
font-size: 20px;
font-family: times new roman;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<description>
Full Stack Developer
</description>
<ul class="sidebar">
<li>
<a href="#">
<i class="fa fa-home"></i>
<span>
My Projects
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-question-circle"></i>
<span>Nothing</span>
</a>
</li>
<li>
<a>
<i class="fa fa-square"></i>
<span>Boxes for all</span>
</a>
</li>
<li>
<a>
<i class="fa fa-th-large"></i>
<span>More boxes</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-info-circle"></i>
<span>
About
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-eye"></i>
<span>I have eyes</span>
</a>
</li>
<li>
<a>
<i class="fa fa-bed"></i>
<span>and a bed</span>
</a>
</li>
<li>
<a>
<i class="fa fa-heartbeat"></i>
<span>plus cool icons</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-globe">
</i>
<span>
Links
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-external-link"></i>
<span>No Links</span>
</a>
</li>
<li>
<a>
<i class="fa fa-fire"></i>
<span>For the wicked</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-envelope-o"></i>
<span>
Contact
</span>
</a>
<ul>
<li>
<a href="mailto:alec.menke#gmail.com">
<i class="fa fa-user"></i>
<span style="font-size: 8px;">alec.menke#gmail.com</span>
</a>
</li>
</ul>
</li>
</ul>
Code Pen
The problem wasn't the vendor prefixes for transforms and transition. The problem was z-index: -1 property. By definition, element with absolute position should be on top of all the elements positioned inline or relative. The trick with -1 worked and placed it below the parent menu element which has position relative. However, in Firefox and IE it was placed even below the body, so when the mouse hovers on dropped menu in fact in hovers on body, i.e. out of the parent menu <li> element.
To solve this problem I made the changes:
In the ul.sidebar > li > a class changed z-index to 1, and added the following properties to the ul.sidebar > li > a class:
position: absolute;
left: 0;
background: #aa2266;
z-index: 1;
I've checked the result on Firefox and Internet Explorer and now it works fine :)
ul.sidebar {
display: block;
position: absolute;
margin: 0;
left: 0;
height: 100%;
width: 6.5em;
background: #aa2266;
padding: 0;
text-align: center;
}
ul.sidebar * {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
ul.sidebar a {
color: white;
text-decoration: none;
margin: 0;
display: inline-block;
width: 100%;
height: 100%;
}
ul.sidebar a > i {
margin-top: 0.13333em;
font-size: 2em;
display: block;
margin-bottom: 0.2em;
}
ul.sidebar a > span {
font-size: 0.8em;
font-family: sans-serif;
}
ul.sidebar li {
transition: background 0.3s;
background: #aa2266;
}
ul.sidebar > li {
margin: 0;
padding: 0;
height: 4em;
display: inline-block;
position: relative;
width: 100%;
background: #aa2266;
transition: background 0.3s;
}
ul.sidebar > li:hover {
background: #dc3278;
}
ul.sidebar > li:hover:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 100%;
width: 6px;
background: linear-gradient(to right, rgba(0, 0, 0, 0.25) 0%, transparent 100%);
}
ul.sidebar > li > a {
position: absolute;
left: 0;
background: #aa2266;
z-index: 1;
transition: background 0.3s;
}
ul.sidebar > li > a:hover {
background: #ff5f87;
}
ul.sidebar > li > ul {
overflow: hidden;
height: 4em;
padding: 0;
position: absolute;
z-index: 0;
margin: 0;
color: red;
left: 100%;
transition-delay: 0.3s;
transition-property: transform;
transition-duration: 0.6s;
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
width: auto;
list-style: none;
white-space: nowrap;
top: 0;
background: #dc3278;
}
ul.sidebar > li > ul > li {
overflow: hidden;
background: none;
margin: 0 0px 0 -4px;
padding: 0;
display: inline-block;
width: 6.5em;
height: 4em;
transition: background 0.3s;
}
ul.sidebar > li > ul > li:hover {
background: #fa648c;
}
ul.sidebar li:hover > ul {
-webkit-transform: translateX(0);
transform: translateX(0);
}
ul.sidebar li:hover > ul > li {
color: white;
}
body {
padding: 0;
position: fixed;
margin: 0;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #450f30;
}
description {
position: absolute;
bottom: 0;
right: 0;
padding: 0 0.4em 1em 0;
color: white;
font-size: 20px;
font-family: times new roman;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<description>
Full Stack Developer
</description>
<ul class="sidebar">
<li>
<a href="#">
<i class="fa fa-home"></i>
<span>
My Projects
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-question-circle"></i>
<span>Nothing</span>
</a>
</li>
<li>
<a>
<i class="fa fa-square"></i>
<span>Boxes for all</span>
</a>
</li>
<li>
<a>
<i class="fa fa-th-large"></i>
<span>More boxes</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-info-circle"></i>
<span>
About
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-eye"></i>
<span>I have eyes</span>
</a>
</li>
<li>
<a>
<i class="fa fa-bed"></i>
<span>and a bed</span>
</a>
</li>
<li>
<a>
<i class="fa fa-heartbeat"></i>
<span>plus cool icons</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-globe">
</i>
<span>
Links
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-external-link"></i>
<span>No Links</span>
</a>
</li>
<li>
<a>
<i class="fa fa-fire"></i>
<span>For the wicked</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-envelope-o"></i>
<span>
Contact
</span>
</a>
<ul>
<li>
<a href="mailto:alec.menke#gmail.com">
<i class="fa fa-user"></i>
<span style="font-size: 8px;">alec.menke#gmail.com</span>
</a>
</li>
</ul>
</li>
</ul>

Resources