CSS: transform 1 pixel shift on Chrome - html

In the actual version of the Chrome browser there is a little issue when transition of this code finishes: 1 pixel shift of the line height on the bottom (on hover of the links).
Also, I've noticed that in code snippets of jsfiddle and here it may not be visible, but on the CodePen and on my website this is what happens. Checked on Firefox - everything is fine and on every web site.
Here is snippet of Stack Overflow and CodePen:
https://codepen.io/Maxim222/pen/OQWWEB
body{
background:#111;
}
ul{
margin:0;
padding:0;
list-style:none;
}
ul li{
float:left;
position:relative;
}
li a{
padding:10px;
color:#fff;
text-decoration:none;
}
li a:before{
content:'';
-webkit-transform: scaleX(0);
transform: scaleX(0);
background-color: #fb0;
bottom: 0px;
height: 15px;
left: 0;
margin: 0;
padding: 0;
position: absolute;
width: 100%;
transition:all 1s;
}
li a:hover:before{
bottom:0;
transform: scaleX(1);
-webkit-transform: scaleX(1);
}
<div>
<ul>
<li>Hello</li>
<li>Worldsdfsdf</li>
</ul>
</div>

From what I know, it's not your fault, it's a "glitch" with the scaleX param. If you use 0.99 as a value instead of 1, it should work fine.
body {
background: #111;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
ul li {
float: left;
position: relative;
}
ul li a {
padding: 10px;
color: #fff;
text-decoration: none;
}
ul li a:before {
content: '';
-webkit-transform: scaleX(0);
transform: scaleX(0);
background-color: #fb0;
bottom: 0px;
height: 15px;
left: 0;
margin: 0;
padding: 0;
position: absolute;
width: 100%;
transition: all 1s;
}
ul li a:hover:before {
bottom: 0;
transform: scaleX(0.99);
-webkit-transform: scaleX(0.99);
}
<div>
<ul>
<li>Hello</li>
<li>Worldsdfsdf</li>
</ul>
</div>

Related

NAV menu doesn't appear on top

How do i make my nav menu permanently on top? I have two nav menu's on a page - a main hamburger nav menu that clicks and pops up, and then an embedded page nav menu
I would like the hamburger nav menu to be permanently on top, but for some reason the embedded nav menu appears through.
Here is a codepen of the issue: https://codepen.io/TheGreatEscape/pen/ebYgGO
Here is a short youtube video if the issue: https://youtu.be/sWzCLOzRJUQ
and the related CSS Code:
/*===== NAV BUTTONS ===*/
#menu-button{ display:none}
a {
-webkit-transition: .3s all ease;
-o-transition: .3s all ease;
transition: .3s all ease;
}
a:hover, a:active, a:focus {
outline: none;
float:none;
clear:both;
text-align:center;
display:inline-block;
position:absolute;
left:0;
right:0 }
.templateux-navbar {
position: fixed;
top: 0px;
left: 0;
width: 100%;
padding: 0;
z-index: 99999;
}
.templateux-navbar .container-fluid {
max-width: 100%;
}
.templateux-navbar .toggle-menu {
z-index: 9999;
}
.templateux-navbar .templateux-menu {
top:35px;
float:none;
clear:both;
text-align:center;
display:inline-block;
position:absolute;
right:210px
}
.templateux-navbar .templateux-menu ul {
position:relative;
float:right;
margin-bottom: 0;
margin-top: 18.5px;
right:178px;
}
.templateux-navbar .templateux-menu ul li {
display: block;
}
.templateux-navbar .templateux-menu ul li a {
left:30px;
top:.5px;
text-decoration: none;
border-radius:0; border:none;
line-height:40px;
display:block;
margin-right: 0px;
font-size: 13px;
text-transform: uppercase;
letter-spacing: .05em;
color: #1a1a1a;
position: relative;
padding-bottom: 5px;
}
.templateux-navbar .templateux-menu ul li a:before {
content: "";
position: absolute;
bottom: 6px;
height: 3px;
width: 0;
left: 0px;
background: #f70f4d;
-webkit-transition: .45s width ease;
-o-transition: .45s width ease;
transition: .45s width ease;
}
.templateux-navbar .templateux-menu ul li a:hover:before {
width: 100%;
}
.templateux-navbar .templateux-menu ul li a:hover {
text-decoration: none;
background-color: inherit;
border:none;
color:#1a1a1a;
font-weight:bold
}
.templateux-navbar .templateux-menu ul li h5 {
position: absolute;
text-decoration: none;
background-color: inherit;
left: 125px;
top: -8px;
color:#1a1a1a;
font-weight:bold;
font-size: 13px;
border-radius:0;
border:none;
line-height:40px;
display: inline-block;
width: 100%;
letter-spacing: .1em;
}
.templateux-navbar .templateux-menu ul li.active > a:before {
width: 100%;
}
.templateux-navbar .templateux-menu ul li:last-child a {
margin-right: 0;
}
/*===== BACKGROUND MENU FOR MENU BUTTON, GET IN TOUCH ===*/
.menu {
width: 33px;
height: 33px;
padding: 5px;
display: block;
cursor: pointer;
position: relative;
float: right;
right: -56px;
top: 24px;
z-index: 1;
}
.menu span {
cursor: pointer;
height: 3.25px;
width: 24px;
margin-bottom: 3px;
background: #000;
position: relative;
right: 0;
display: block;
transform: rotate(0deg);
transition: .7s ease;
}
.hidden {
opacity: 0;
transition-delay: .5s;
pointer-events: none;
cursor: default;
}
.visible {
opacity: .97;
}
.menu.open span:nth-child(1) {
top: 10px;
transform: rotate(180deg);
transition: .7s ease;
background: #ffffff;
}
.menu.open span:nth-child(2) {
opacity: 0;
right: 100px;
background: #000;
}
.menu.open span:nth-child(3) {
top: 0px;
transform: rotate(-180deg);
transition: .8s ease;
background: #ffffff;
}
#navigation {
background: #000000;
font-family: 'Titling Gothic Bold';
color: rgb(0, 0, 0);
font-size: 0px;
width: 100%;
height: 450px;
text-align:left;
}
Your issue is the z-index. I fixed it by adding the class hamburger to your first .templateux-navbar element and then modified your CSS a bit. You can see the modified CSS below.
.templateux-navbar {
position: fixed;
top: 0px;
left: 0;
width: 100%;
padding: 0;
z-index: 9;
}
.templateux-navbar.hamburger {
z-index: 10;
}
Your code has this issue because you gave both the menus the same z-index so it means that the element that is defined next in the HTML will naturally get higher priority, which in your case is your second nav.
Making your hamburger menu have a higher z-index solves this issue.

Icons not aligning properly on resizing screen

I have these two icons that I have placed at the bottom right of my page with a fixed position.
It is working perfectly on larger screens but the icons move as the screen is resized.
HTML
<div class="general_social_icons">
<nav class="social">
<ul>
<li class="w3_facebook">Facebook </li>
<li class="w3_g_plus">Google+ </li>
</ul>
</nav>
</div>
CSS:
.social {
position: fixed;
bottom: 0%;
right:0%;
width: 4%;
z-index: 9999;
}
.social li a{
font-size:.7em;
}
.social ul {
padding: 0px;
}
.social ul li {
display: block;
margin: 5px;
width: 310px;
text-align: left;
padding: 10px;
-webkit-border-radius: 30px 0 30px 30px;
-moz-border-radius: 30px 0 30px 30px;
border-radius: 30px 0 30px 30px;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s;
-o-transition: all 1s;
transition: all 1s;
}
.w3_facebook{
background:#3b5998;
}
.w3_g_plus{
background:#dd4b39;
}
.social ul li:hover {
-webkit-transform: translate(-110px, 0);
-moz-transform: translate(-110px, 0);
-ms-transform: translate(-110px, 0);
-o-transform: translate(-110px, 0);
transform: translate(-130px, 0);
}
.social ul li a{
color:#212121;
}
.social ul li:hover a {
color: #fff;
text-decoration: none;
}
Here is the fiddle:https://jsfiddle.net/746d9nyc/2/
How can I make sure that the icons stay at the same position at any screen size as they are on full screen.
This is happening because your .social container has a percentage width.
To solve it either:
• assign a fixed width
.social {
width:27px;
}
• set a minimum width
.social {
min-width:27px;
}
The problem is that you have the width on .social set as a percentage.
.social {
position: fixed;
bottom: 0%;
right:0%;
width: 150px; // or some fixed value
z-index: 9999;
}
updated fiddle: https://jsfiddle.net/746d9nyc/3/

Max height of ul is limited to a single nested li item

Making a slide down drop menu animation, if I set max height to 100% the <ul> will only extend its height to the first nested <li>. I can set the max-height in the Keyframe to 400%, but this causes to animation to go twice as fast in other drop downs with less submenus. The height of the <ul> before I hover over seems to be the full size when debugging, not sure why it gets limited in the animation.
And as a secondary question, will I run into browser support issues using animations like this?
JSFiddle
#keyframes slideDown {
0% {
max-height: 0%;
opacity: .2;
}
100% {
max-height: 400%;
opacity: 1;
}
}
#menuTabs {
float: left;
position: absolute;
margin-left: 0px;
background: #256AAA none repeat scroll 0% 0%;
width: 100%;
overflow: visible;
}
#menuTabs ul {
left: 50%;
margin: 0px;
clear: left;
float: left;
padding: 0px;
font-size: 15px;
position: relative;
text-align: center;
font-family: helvetica;
list-style: outside none none;
}
#menuTabs ul li {
margin:0;
padding:0;
right:50%;
float:left;
display:block;
list-style:none;
min-width: 170px;
max-width: 170px;
position:relative;
}
#menuTabs ul li a {
color:#000;
display:block;
background:#ddd;
padding:0px 50px;
line-height:1.3em;
text-decoration:none;
font-family:'Oxygen', sans-serif;
color: #FFF;
margin-top: 0px;
font-weight: bold;
padding: 15px 50px;
text-decoration: none;
background: #Blue;
}
#menuTabs ul li:hover > a {
visibility: visible;
text-decoration: none;
background: #CCC;
}
ul#menu li.selected a {
color: #000;
background-color: #fff;
}
#menuTabs ul li ul {
margin: 0;
padding: 0;
width: 100%;
visibility: hidden;
overflow: hidden;
position: absolute;
left: 0%;
max-height: 0%;
}
#menuTabs ul li ul a {
z-index: 1;
display: block;
font-size: 12px;
max-width: 70px;
min-width: 120px;
min-height: 22px;
overflow: visible;
position: relative;
padding: 14px 25px;
background: #256AAA none repeat scroll 0% 0%;
}
#menuTabs ul li ul a:hover {
background: #CCC;
}
#menuTabs ul li:hover ul {
visibility: visible;
position: absolute;
background: #CCC;
}
#menuTabs ul li:hover ul {
max-height: 0%;
animation-name: slideDown;
animation-duration: 2s;
animation-fill-mode: forwards;
}
#menuTabs ul li ul li {
left: 0%;
display: block;
}
<div id="menuTabs">
<ul id="menu">
<li> Services
<ul id="class">
<li id="srv1"> SubMenu
</li>
<li id="srv2"> SubMenu2
</li>
</ul>
<li>Resources
<ul>
<li> SubMenu2</li>
<li> SubMenu3</li>
<li> SubMenu4</li>
<li> SubMenu5</li>
</ul>
</li>
</li>
</ul>
</div>
I would do it by just using transition instead of keyframes for that, it runs smoother, and much easier. I haven't found a way to do the dynamic height thing, so I think you'll have to pick a height with the max number of items you're possibility going to have.
jsfiddle
#menuTabs ul li ul {
...
max-height: 0;
transition: all .1s ease-out;
opacity: .5;
}
#menuTabs ul li:hover ul {
...
max-height: 400%;
transition: all .25s ease-in;
opacity: 1;
}

CSS multilvel menu issue at third level

I've made a three level menu in HTML and CSS.
The menu works until the third level (under products). The third ul sub-menu isn't displaying properly. It's being aligned improperly. I want it to get out of it's parent menu and be positioned at the right.
Here is a jsfiddle with my code.
I've changed some postions of ul, li but they don't seem to be working for me.
CSS, HTML in the fiddle:
#nav,#nav ul {
list-style: none outside none;
margin: 0;
padding: 0;
}
#menucon {
width:100%;
background-color:#222;
}
#nav {
clear: both;
font-size: 12px;
height: 42px;
}
#nav ul {
background-color: #222;
background-color: rgba(34,34,34,0.70);
border:1px solid #222;
border-radius: 0 5px 5px 5px;
border-width: 0 1px 1px;
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.5);
left: -9999px;
overflow: hidden;
position: absolute;
top: -9999px;
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
-o-transform: scaleY(0);
-webkit-transform: scaleY(0);
transform: scaleY(0);
}
#nav ul.sec { z-index: 2; }
#nav ul.third { z-index: 3; border:2px solid red; }
#nav li {
background: url('menu_line.png') no-repeat scroll right 5px transparent;
float: left;
position: relative;
}
#nav li a {
color: #FFFFFF;
display: block;
float: left;
font-weight: normal;
height: 27px;
padding: 14px 30px 0;
position: relative;
text-decoration: none;
text-shadow: 1px 1px 1px #000000;
}
#nav ul.subs li a {
color: #FFFFFF;
display: block;
float: left;
font-weight: normal;
height: 27px;
padding: 13px 25px 0;
position: relative;
width:178px;
text-decoration: none;
text-shadow: 1px 1px 1px #000000;
}
#nav li:hover > a {
color: #00B4FF;
}
#nav li:hover, #nav a:focus, #nav a:hover, #nav a:active {
background: none repeat scroll 0 0 #121212;
outline: 0 none;
}
#nav li:hover ul.subs.sec {
left: 0;
top: 41px;
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-o-transform: scaleY(1);
-webkit-transform: scaleY(1);
transform: scaleY(1);
position:absolute;
}
#nav li:hover ul.subs.third {
left: 60px; /* test */
top: 41px;
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-o-transform: scaleY(1);
-webkit-transform: scaleY(1);
transform: scaleY(1);
position:absolute;
}
#nav ul li {
background: none;
width: 100%;
}
#nav ul li.sec {position:relative;}
#nav ul li a {
float: none;
}
#nav ul li:hover > a {
background-color: #121212;
color: #00B4FF;
}
#lavalamp {
background: url('lavalamp.png') no-repeat scroll 0 0 transparent;
height: 16px;
left: 32px;
position: absolute;
top: 0px;
width: 64px;
-moz-transition: all 400ms ease-out ;
-ms-transition: all 400ms ease-out ;
-o-transition: all 400ms ease-out ;
-webkit-transition: all 400ms ease-out ;
transition: all 400ms ease-out ;
}
#lavalamp:hover {
-moz-transition-duration: 4500s;
-ms-transition-duration: 4500s;
-o-transition-duration: 4500s;
-webkit-transition-duration: 4500s;
transition-duration: 4500s;
}
#nav li:nth-of-type(1):hover ~ #lavalamp, #lavalamp.act1 {
left: 35px;
}
#nav li:nth-of-type(2):hover ~ #lavalamp, #lavalamp.act2 {
left: 180px;
}
#nav li:nth-of-type(3):hover ~ #lavalamp, #lavalamp.act3{
left: 345px;
}
#nav li:nth-of-type(4):hover ~ #lavalamp, #lavalamp.act4 {
left: 486px;
}
#nav li:nth-of-type(5):hover ~ #lavalamp, #lavalamp.act5 {
left: 620px;
}
<div id="menucon">
<ul class="innercon" id="nav">
<li>HOME PAGE</li>
<li>PRODUCTS
<ul class="subs sec">
<li class="sec">LEVEL 1
<ul class="subs third">
<li>LEVEL 2</li>
<li>LEVEL 2</li>
</ul>
</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
</ul>
</li>
<li>CONTACT US</li>
<div id="lavalamp"></div>
</ul>
</div>
Here is a DEMO to try if it fits your problem.
You gonna have to add this just this css:
.third{
display: none;
}
li > ul.sec > li:hover > ul.third {
display: inline-block;
position: absolute;
left: 100%!important;
top: 0!important;
z-index: 9;
width: 150px;
}
Explanation:
when you hover your second level item (li) you will show your submenu 100% left, i.e. next to the hovered li and top: 0 will place it inline with the hovered li.
You can adjust the width and z-index for your needs.
is this what you wanted?
Your question is still kinda unclear what you want.
ul.sec {
overflow: visible !important;
}
.subs .third {
left: 228px !important;
top: 41px !important;
}
https://jsfiddle.net/gsw4jxy8/4/

Animate height of menu bar in CSS

What I really want is to have the same effect on the website of www.ditto.com by the menu, if anyone can figure that out, it would be really great, but if not this is what I have and please if anyone can answer this question, I'm in the middle of making a website for someone and I need this info fast!!
This code waits 0.8s when going up but it doesn't wait when it goes down, it just pops down.
Thanks in advance!!
You can see the full code here here: http://jsfiddle.net/zZPPR/
CSS
.one
{
max-height: 0;
overflow: hidden;
-webkit-transition: max-height 0.8s;
}
.two
{
max-height: 200px;
overflow:visible;
}
Here is a solution that target the second animation in the link. Still a draft though.
http://jsfiddle.net/NicoO/T4Nbk/5/
Update: Max-height is causing speed issues, making the feeling the transition too fast or slow. Here is an alternative solution using transforms: http://jsfiddle.net/NicoO/T4Nbk/7/ same version with Chrome vendor prefixes: http://jsfiddle.net/T4Nbk/9/
CSS:
ul
{
margin: 0;
padding: 0;
}
ul > li
{
display: inline-block;
position: relative;
}
ul > li li
{
display: block;
}
ul > li:before
{
background-color:gray;
top: 100%;
bottom:0;
left: 0;
right: 0;
position: absolute;
content: "";
transition-duration: 0.4s;
z-index:-1;
}
ul > li a
{
display: block;
position: relative;
}
ul > li ul
{
max-height: 0;
overflow: hidden;
position: absolute;
left:0;
width: 300px;
background-color: gray;
transition-duration: 0.4s;
transition-property: max-height;
}
ul > li:hover:before
{
top:0;
}
ul > li:hover ul
{
max-height: 400px;
}
HTML:
<nav>
<ul>
<li>Home</li>
<li>News & Events</li>
<li>
Discover
<ul>
<li>Jordan</li>
<li>Jordan</li>
</ul>
</li>
</ul>
</nav>
CSS of the solution using transforms:
Inspired by: How can I transition height: 0; to height: auto; using CSS?
ul
{
margin: 0;
padding: 0;
}
ul > li
{
display: inline-block;
position: relative;
}
ul > li li
{
display: block;
}
ul > li:before
{
background-color:gray;
top: 100%;
bottom:0;
left: 0;
right: 0;
position: absolute;
content: "";
transition-duration: 0.4s;
z-index:-1;
}
ul > li a
{
display: block;
position: relative;
}
ul > li ul
{
transform: scaleY(0);
transition: transform 0.4s;
transform-origin: top;
overflow: hidden;
position: absolute;
left:0;
width: 300px;
background-color: gray;
}
ul > li:hover:before
{
top:0;
}
ul > li:hover ul
{
transform: scaleY(1);
}
What's happening is that you're not transitioning the overflow property. So as soon as the class two is applied, the overflow is set to visible and the content shows immediately.
Remove the overflow:visible from the class .two and it will work
JSFIDDLE
You should remove overflow:visible;