I am working on a <nav> for a mobile site. It is working file in Firefox and Chrome but not in Safari. I am running it on Windows 8.1 and I observed the same issue on Safari in iPad mini.
In the snippet below, if you check out the mobile view (max-width: 768px) and click on the menu icon in the top right corner, that icon is suppose to animate to a cross (X) icon, also the nav menu is suppose to slide down.
$("a.nav-opener").click(function(e) {
e.preventDefault();
$('body').toggleClass("nav-active");
});
#media screen and (max-width: 768px){
.holder {
padding: 14px;
}
.logo {
float: none;
display: block;
margin: 0px auto;
width: 168px;
position: relative;
z-index: 2;
}
a {
text-decoration: none;
color: #DC7952;
outline: medium none;
}
.logo img {
width: 100%;
height: auto;
display: block;
}
img {
max-width: 100%;
height: auto;
}
.nav-opener {
display: block;
position: absolute;
top: 0px;
right: 0px;
border-left: 1px solid #D4D4D4;
width: 65px;
height: 53px;
text-indent: -9999px;
overflow: hidden;
background: none repeat scroll 0% 0% transparent;
z-index: 15;
}
.nav-opener::before, .nav-opener::after {
content: "";
top: 19px;
}
.nav-opener::before, .nav-opener::after, .nav-opener span {
background: none repeat scroll 0% 0% #DC7952;
position: absolute;
left: 15%;
right: 15%;
height: 6px;
margin-top: -2px;
transition: all 0.2s linear 0s;
}
.nav-opener::after {
top: 37px;
}
.nav-opener span {
background: none repeat scroll 0% 0% #DC7952;
position: absolute;
top: 28px;
left: 15%;
right: 15%;
height: 6px;
margin-top: -2px;
transition: all 0.2s linear 0s;
}
.nav-active .nav-opener::after, .nav-active .nav-opener::before {
transform: rotate(45deg);
border-radius: 3px;
top: 24px;
left: 15%;
right: 15%;
}
.nav-active .nav-opener::after {
transform: rotate(-45deg);
}
.nav-opener::before, .nav-opener::after {
content: "";
}
.nav-active .nav-opener span {
display: none;
}
.navigation-container {
border: 0px none;
overflow: hidden;
position: absolute;
top: 53px;
left: 0px;
right: 0px;
z-index: 999;
max-height: 0px;
transition: all 0.25s linear 0s;
margin: 0px;
padding: 0px;
}
.nav-active .navigation-container {
max-height: 4000px;
}
.navigation-container .drop {
transition: all 0.25s linear 0s;
transform: translateY(-100%);
background: none repeat scroll 0% 0% #FFF;
width: 100%;
display: table;
}
.nav-active .drop {
transform: translateY(0px);
}
#nav {
margin: 0px;
overflow: visible;
font-size: 24px;
display: table-header-group;
font-family: "apercu",sans-serif;
font-weight: 700;
line-height: 1.4285;
text-transform: uppercase;
}
#nav ul {
display: block;
border-top: 1px solid #E8E8E8;
padding: 0px;
width: 100%;
margin: 0px;
}
#nav li {
display: block;
width: auto;
border-style: solid;
border-color: #E8E8E8;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
border-width: 0px 0px 1px;
list-style: outside none none;
}
#nav li.active a, #nav li a:hover {
text-decoration: none;
color: #FFF;
background: none repeat scroll 0% 0% #DC7952;
}
#nav a {
display: block;
text-align: left;
padding: 15px 20px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="holder">
<strong class="logo">Some logo</strong>
</div>
<!-- navigation opener -->
<span>opener</span>
<div class="navigation-container">
<div class="drop">
<!-- main navigation of the page -->
<nav id="nav">
<ul>
<li class="active">HOME</li>
<li>BIBLE RESOURCES</li>
<li>OUR MISSION</li>
</ul>
</nav>
</div>
</div>
Equivalent jsFiddle
Can anyone point me in the right direction?
Transform and transition don't work on safari and chrome without browser perfix that is webkit for safari so use:
-webkit-transform and -webkit-transition instead...
the transform property need to be prefixed in safari
for ex.: -webkit-transform
for any other resource check this
Apple stopped releasing Safari latest versions for windows long back (2012). Might be your using old Safari browser which is not compatible with CSS3..
Chrome and latest safari works on webkit rendering engine.. If it works in chrome then it will work same on safari as well.
Safari Versions which support transform:
http://caniuse.com/#feat=transforms2d
Correct me if i'm wrong :)
As mentioned in http://html-tuts.com/fix-laggy-transitions-in-css/ you also need to add an extra property when you work with Safari and transition, or else it can get laggy.
You do this by adding the css property transform with the value translateZ(0) to the element with the transition property - in this case:
.nav-opener span {
...
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);
}
Related
I am new to coding, I have tried various solutions from similar questions asked, but nothing seems to work.
I have the following problem:
I made a breadcrumb, including various divs with :before and :after elements - shaping them like connected arrows.
The problem is, I made an animation for the breadcrumb element to fade-in-down. However, no matter in what combination I tried -> The :after element does not animate properly, or at all.
It kinda just pops up after :before and the parent div .breadcrumb have finished sliding in. Can anybody help me here, or has anyone maybe have aa clue?
... I have tried animating the :after element separatly, with transition, with animation-delay etc...nothing seems to work...everything slides in fine from top, excep the :after element, which just pops up ugly after the animation from my ".breadcrumb" is finished.
<div class="breadcrumb_wrapper">
Lasermaschinen
Serien
Unterserien
Produkt
.breadcrumb_wrapper {
position: fixed;
display: flex;
align-items: center;
width: 100%;
height: auto;
margin-top: 120px;
text-align: center;
}
.breadcrumb_element {
padding: 0 2rem 0 2rem;
width: auto;
line-height: 32px;
min-height: 32px;
max-height: 32px;
background: var(--Breadcrumb-gradient);
position: relative;
text-align: center;
margin-left: 0.5rem;
color: var(--nav-text-color-and-general-background);
cursor: pointer;
text-decoration: none;
animation: fade-in-down 0.5s ease-in-out;
}
.breadcrumb_element:before {
content: "";
position: absolute;
top: 4.69px;
left: -11.32px;
width: 22.427px;
height: 22.427px;
background: var(--nav-text-color-and-general-background);
transform: rotate(45deg);
z-index: 1;
border-top: 1px solid #F0F0F0;
border-right: 1px solid #F0F0F0;
border-top-right-radius: 5px;
}
.breadcrumb_element:after {
content: "";
position: absolute;
top: 4.69px;
right: -11.6px;
width: 22.427px;
height: 22.427px;
background: var(--Breadcrumb-arrow-gradient);
transform: rotate(45deg);
z-index: 2;
border-top-right-radius: 5px;
animation: fade-in-down 0.5s ease-in-out;
}
#keyframes fade-in-down {
0% {
opacity: 0;
transform: translateY(-20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
Without seeing your HTML code I just had to take a guess at how you need this but here is an example with the after pseudo element coming in from the top and sitting on top of the before pseudo. Hope this helps you get what you are looking for. You can have it come in from any direction that you want.
ul {
list-style: none;
display: flex;
overflow: hidden;
}
li {
margin-left: 20px;
margin-right: 20px;
position: relative;
}
li::before {
content: '';
width: 20px;
height: 20px;
background-color: green;
position: absolute;
right: -25px;
}
li::after {
content: '';
width: 20px;
height: 20px;
background-color: red;
position: absolute;
right: -25px;
top: -100px;
transition: all 1s;
}
li:hover:after {
top: 0;
}
<ul>
<li>Menu Item 1</li>
<li>Menu Item 2</li>
</ul>
I would like to know the CSS code used to make the underline effect for the menu items of this website : https://www.kevin-missud-charpente.fr/
Thanks in advance.
this is better
body,html {
margin: 0;
font: bold 14px/1.4 'Open Sans', arial, sans-serif;
background: #fff;
}
ul {
margin: 150px auto 0;
padding: 0;
list-style: none;
display: table;
width: 600px;
text-align: center;
}
li {
display: table-cell;
position: relative;
padding: 15px 0;
}
a {
color: #000;
text-transform: uppercase;
text-decoration: none;
letter-spacing: 0.15em;
display: inline-block;
padding: 15px 20px;
position: relative;
}
a:after {
background: none repeat scroll 0 0 transparent;
bottom: 0;
content: "";
display: block;
height: 2px;
left: 50%;
position: absolute;
background: #000;
transition: width 0.3s ease 0s, left 0.3s ease 0s;
width: 0;
}
a:hover:after {
width: 100%;
left: 0;
}
#media screen and (max-height: 300px) {
ul {
margin-top: 40px;
}
}
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
<li>Support</li>
</ul>
this is on hover underline effect
Here a link to codepen with the same underline animation.
https://codepen.io/Nerd/details/zBmAWV
HTML
<nav>
Hover me!
</nav>
CSS
nav {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
a {
position: relative;
color: #000;
text-decoration: none;
font-size: 42px;
font-family: sans-serif;
&:hover {
color: #000;
&:before {
visibility: visible;
transform: scaleX(1);
}
}
&:before {
content: "";
position: absolute;
width: 100%;
height: 3px;
bottom: 0;
left: 0;
background-color: #000;
visibility: hidden;
transform: scaleX(0);
transition: all 0.3s ease-in-out 0s;
}
}
I am trying to write code that mimics this animation as much as possible.
I have been going over keyframe animations & I think that they can be used to do what I need them to do.
I effectively want to have three things happen when the user hovers over the parent element. The first is the color
on the right side of the element will change dynamically (as in the picture & as in the example code), the
icon will animate into the picture & then the text will then animate.
I am new to programming & I am looking for some direction.
Example of finished product: https://imgur.com/a/bxV1V1B
DEMO
.wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
a {
display: block;
width: 200px;
height: 40px;
line-height: 40px;
font-size: 18px;
font-family: sans-serif;
text-decoration: none;
color: #333;
border: 2px solid #333;
letter-spacing: 2px;
text-align: center;
position: relative;
transition: all .35s;
}
a span {
position: relative;
z-index: 2;
}
a:after {
position: absolute;
content: "";
top: 0;
right: 0;
width: 0;
height: 100%;
background: green;
transition: all .35s;
}
a:hover:after {
width: 15%;
}
<div class="wrapper">
<span>Hover Me!</span>
</div>
Here you go. I made a CSS animation for you which will rotate and translate a new i that I have added into the HTML. I used font awesome for the check with the circle around it. Take a look:
.wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
a {
display: block;
width: 200px;
height: 40px;
line-height: 40px;
font-size: 18px;
font-family: sans-serif;
text-decoration: none;
color: #333;
border: 2px solid #333;
letter-spacing: 2px;
text-align: center;
position: relative;
transition: all .35s;
}
a span {
position: relative;
z-index: 2;
}
a:after {
position: absolute;
content: "";
top: 0;
right: 0;
width: 0;
height: 100%;
background: green;
transition: all .35s;
visibility: hidden;
}
a:hover:after {
width: 15%;
visibility: visible;
}
#check {
right: 2px;
top: 8px;
position: absolute;
display: none;
z-index: 3;
transition: right .35s;
}
a:hover #check {
animation:spin .35s linear;
display: block;
}
#keyframes spin {
0% {
transform: translate(25px) rotate(0deg);
}
100% {
transform: translate(0px) rotate(360deg);
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="wrapper">
<span>Hover Me!</span><i id="check"style="font-size:22px; color:lightgrey" class="fa fa-check-circle"></i>
</div>
I'm building a website currently and am experiencing issues with transform: scale. I've got a button, and when a user hovers over it, two things happen:
A background "sweeps" in diagonally
The button label colour changes
The button grows slightly
I have got this working, and it looks really nice, but after implementing point 3, I'm seeing a weird gap to the left hand side when the button grows.
Here is my code: click for demo
HTML
Hover
CSS
body {
text-align: center;
padding-top: 10%;
}
.button {
display: inline-block;
text-transform: uppercase;
font-size: 1.1em;
font-weight: 600;
background: transparent;
transition: all ease .25s;
border: 3px solid green;
color: green;
position: relative;
overflow: hidden;
z-index: 2;
font-family: sans-serif;
padding: 20px 35px;
text-decoration: none;
}
.button:before {
content: ' ';
transition: all ease-out .25s;
width: 200%;
height: 100%;
position: absolute;
top: 0;
left: 0;
transform-origin: 0 0;
z-index: -1;
transform: skewX(-45deg) translateX(-100%);
background: green;
}
.button:hover:before {
transform: translateX(0);
}
.button:hover {
color: white;
transform: scale(1.1);
}
And here's a screenshot of the gap I'm seeing. This issue occurs in Chrome and Safari (I haven't tested Firefox or IE as I can't download them at work).
Screenshot of weird gap
It "only" appears in Chrome but not Firefox (edit: worse in Edge: first it's on the left then on bottom...). Not sure if a rounding error or something else is the cause of that gap, but I find that replacing border by a box-shadow improves the rendering.
There's still a gap that can be seen near the end of the transition but finally disappears so I added 2 box-shadows on :hover: the new one is inset and fills the gap between "border/box-shadow" and content box faster.
Codepen: http://codepen.io/PhilippeVay/pen/oYjZzK?editors=0100
body {
text-align: center;
padding-top: 10%;
}
.button {
display: inline-block;
text-transform: uppercase;
font-size: 1.1em;
font-weight: 600;
background: transparent;
transition: all ease .25s;
box-shadow: 0 0 0 3px green; /* replaces border which caused a gap in Chr, not Fx */
color: green;
position: relative;
overflow: hidden;
z-index: 2;
font-family: sans-serif;
padding: 19px 34px;
text-decoration: none;
}
.button:before {
content: ' ';
transition: transform ease-out .25s;
width: 200%;
height: 100%;
position: absolute;
top: 0;
left: 0;
transform-origin: 0 0;
z-index: -1;
transform: skewX(-45deg) translateX(-100%);
background: green;
}
.button:hover:before {
transform: translateX(0);
}
.button:hover {
color: white;
box-shadow: 0 0 0 3px green, inset 0 0 0 1px green; /* improves end of transition in Chrome */
transform: scale(1.1);
}
Hover
EDIT: playing with the size of the transitioned :pseudo
.button:before {
content: ' ';
transition: all ease-out .25s;
width: calc(200% + 6px);
height: calc(100% + 6px);
position: absolute;
top: -3px;
left: -3px;
transform-origin: 0 3px;
z-index: -1;
transform: skewX(-45deg) translateX(-100%);
background: green;
}
to take into account the border but that doesn't change anything because of overflow: hidden.
So here's my third try: by adding a container (or having the A element as a container) and keeping the border on the child element, it makes that gap disappear (overflow is around the border).
Codepen: http://codepen.io/PhilippeVay/pen/ZBbKWd
body {
text-align: center;
padding-top: 10%;
}
a {
display: inline-block;
overflow: hidden;
background: transparent;
transition: all ease .25s;
color: green;
position: relative;
z-index: 2;
font-family: sans-serif;
text-decoration: none;
}
a > span {
display: inline-block;
text-transform: uppercase;
font-size: 1.1em;
font-weight: 600;
border: 3px solid green;
padding: 20px 35px;
}
a:before {
content: ' ';
transition: all ease-out .25s;
width: 200%;
height: 100%;
position: absolute;
top: 0;
left: 0;
transform-origin: 0 0;
z-index: -1;
transform: skewX(-45deg) translateX(-100%);
background: green;
}
a:hover:before {
transform: translateX(0);
}
a:hover {
color: white;
transform: scale(1.1);
}
<span class="bd">Hover</span>
Fx transitions till the end flawlessly... and "corrects" the width by adding 2px on the right. But it's already visible in your jsbin so it's another story (and less annoying I guess as user will have clicked by then imho)
I have a nav element that on mouse hover reveal my menu, it works fine on Safari and Chrome however not in Firefox nor in IE:
/* start nav menu morph */
nav {
width: 23%;
background: #222222;
color: rgba(255, 255, 255, 0.87);
-webkit-clip-path: circle(16px at 30px 24px);
clip-path: circle(16px at 30px 24px);
-webkit-transition: -webkit-clip-path 0.5625s, clip-path 0.375s;
transition: -webkit-clip-path 0.5625s, clip-path 0.375s;
}
nav:hover {
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
-webkit-transition-duration: 0.75s;
transition-duration: 0.75s;
-webkit-clip-path: circle(500px at 225px 24px);
clip-path: circle(500px at 225px 24px);
}
nav a {
width: 100%;
display: block;
line-height: 50px;
padding: 0 20px;
color: inherit;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
nav a:hover {
background: #ffe082;
}
nav a:active {
background: #ffca28;
}
.nav-sim {
position: absolute;
right: 0;
top: -6px;
}
.navicon {
padding: 23px 20px;
cursor: pointer;
-webkit-transform-origin: 32px 24px;
-ms-transform-origin: 32px 24px;
transform-origin: 32px 24px;
}
.navicon div {
position: relative;
width: 20px;
height: 2px;
background: rgb(254, 70, 70);
}
.navicon div:before,
.navicon div:after {
display: block;
content: "";
width: 20px;
height: 2px;
background: rgb(254, 70, 70);
position: absolute;
}
.navicon div:before {
top: -7px;
}
.navicon div:after {
top: 7px;
}
.fa-sim {
font-size: large;
margin-left: 5px;
}
/* end nav menu morph */
<noscript>
<style>
#navmenusim {
display: none;
}
</style>
</noscript>
<nav class="nav-sim" id="navmenusim">
<div class="navicon">
<div></div>
</div>
Home<i class="fa fa-home icon i-sim fa-sim"></i>
Blog<i class="fa fa-rss icon i-sim fa-sim"></i>
Contact<i class="fa fa-mail icon i-sim fa-sim"></i>
</nav>
The menu in Firefox and IE is always visible, the clip-path doesn't work. How to fix it?
As mentioned in my comment to the question, CSS clip-path won't work in Firefox. You would need to use SVG along with url() syntax for Firefox support. IE (even 11 and Edge) supports neither the CSS or SVG version of clip-path. You can check browser compatibility chart at Can I Use.
You can make use of the max-width, max-height, border-radius and overflow properties to sort of get a similar output to what you need. Below is a sample snippet which should work in all browsers.
/* start nav menu morph */
nav {
margin-top: 10px;
width: 23%;
background: #222222;
color: rgba(255, 255, 255, 0.87);
max-height: 50px;
max-width: 50px;
border-radius: 50%;
overflow: hidden;
transition: max-height .375s, max-width .375s, border-radius .125s .25s;
}
nav:hover {
max-height: 500px;
max-width: 500px;
border-radius: 0%;
transition: max-height .75s ease-out, max-width .75s ease-out, border-radius .75s ease-out;
}
nav a {
width: 100%;
display: block;
line-height: 50px;
padding: 0 20px;
color: inherit;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
nav a:hover {
background: #ffe082;
}
nav a:active {
background: #ffca28;
}
.nav-sim {
position: absolute;
right: 0;
top: -6px;
}
.navicon {
padding: 23px 20px;
cursor: pointer;
-webkit-transform-origin: 32px 24px;
-ms-transform-origin: 32px 24px;
transform-origin: 32px 24px;
}
.navicon div {
position: relative;
margin-left: -5px;
width: 20px;
height: 2px;
background: rgb(254, 70, 70);
}
.navicon div:before,
.navicon div:after {
display: block;
content: "";
width: 20px;
height: 2px;
background: rgb(254, 70, 70);
position: absolute;
}
.navicon div:before {
top: -7px;
}
.navicon div:after {
top: 7px;
}
.fa-sim {
font-size: large;
margin-left: 5px;
}
/* end nav menu morph */
<nav class="nav-sim" id="navmenusim">
<div class="navicon">
<div></div>
</div>
Home<i class="fa fa-home icon i-sim fa-sim"></i>
Blog<i class="fa fa-rss icon i-sim fa-sim"></i>
Contact<i class="fa fa-mail icon i-sim fa-sim"></i>
</nav>