Situation:
View the jsFiddle
Inside of a div I have an image followed by text which has a font-weight of 900 on it. In my locally hosted environment I'm using a custom font, but for the fiddle above I chose the "ever-so-stylish" Comic Sans to illustrate my point. Before anything happens I set the opacity of the entire div to 0.7. However, on hovering over the div, I want the opacity of everything to come to full opacity.
Problem:
I've noticed that in Webkit browsers only (more apparent on Chrome than it is on Safari however), upon hovering on and off the of the div tag, the text's weight will appear to change. In actuality, there's no change at all of course in the weight of the text. However, upon closer review you'll see the text appears at it's desired weight only on hover, but not in a non-hovered state.
Things I've Done:
I've tested this in all the latest versions of Chrome, Firefox, and Safari.
I am testing this currently on the new MacBook Pro which, in my case, is a retina screen. However, the colleague next to me tested the fiddle on her iMac (non-retina display) only to find the issue still apparent.
Perhaps I'm just crazy, but I feel this actually may be how webkit browsers choose to render out elements with different opacities. Then again, that may be just me trying to avoid admitting I did something wrong.
And naturally I thought I could lighten the mood with Comic Sans. Here's a screen capture to help explain the issue:
It's not an issue with the opacity itself (in fact, turning it back to 1 in #Zoltan's example doesn't change anything for me).
The issue is with the transitions, there are two anti-aliasing modes that webkit can use:
Subpixel (the default, but not supported during animations, transitions or transforms) or
Grayscale
This means that when an element is rendered using subpixel antialiasing and an animation is applied to it, webkit temporarily switches to grayscale for the duration of the animation and then back to subpixel once finished.
Given that subixel antialiasing results in a slightly heavier font face you get the unwanted artifact.
To solve the issue, add this to your css:
html {
-webkit-font-smoothing: antialiased;
}
This forces grayscale antialiasing and all the text and you won't see the switching.
(end result: http://jsfiddle.net/ErVYs/9/)
A possible solution would be to make the opacity transition not to 1, but .999 - http://jsfiddle.net/ErVYs/2/
div {
width: 200px;
text-align: center;
opacity: 0.7;
transition: opacity ease-in 0.25s;
-webkit-transition: opacity ease-in 0.25s;
-moz-transition: opacity ease-in 0.25s;
-o-transition: opacity ease-in 0.25s;
}
div:hover {
opacity: .999;
}
Related
I have a site on which I'm transitioning everything between light and dark mode on the flip of a switch.
I'm doing this by giving the body tag a color and background-color which change, and everything on the page is styled using * { transition: color 1s, background 1s; }.
In Firefox, this does exactly what I want. In Chrome and Safari, it has the horrible effect of seemingly queueing up the transitions by... tag name?
Eg. First the container fades, then text, then italic text, then headers, then code blocks, etc. etc.
I haven't the foggiest why this would cause a render engine quirk. Is Firefox right? Is there a spec for this at all? I'm hoping to have the whole page fade at once.
To be clear, the left is Firefox - that's the desired outcome. The right is Safari being very strange, though Chrome is exactly the same.
Here's a link to the site if you'd like to try it out in your browser.
Remove below code:
* {
transition: color 1s, background 1s
}
and add transition property to the body selector
html, body {
transition: all 1s;
}
Hey I am new to development so was trying to change background color when we change menu item, I have done that, but want to have some delay in changing of background color.I tried transition property but got no result.Is transition property not applicable to <body>?As I tried to provide 'id' to <body> and apply rule like this
<body id="color">
CSS
#color {
background-color: yellowgreen;
transition: background-color 2s ;
}
I am doing something wrong? What is the way to apply <div> to full page and apply the same rule?
First, when using transitions, you need to add the -webkit for Safari - http://www.w3schools.com/cssref/css3_pr_transition.asp
If you want a transition effect that takes x amount of time, you can exclude the below transition-delay. But if you want your transition to be delayed by, say 2 seconds, then you can add the transition-delay and set it you the amount of seconds you want to delay the transition for.
#color {
background-color: yellowgreen;
-webkit-transition: background-color 2s ease-in; /* Safari */
transition: background-color 2s ease-in;
-webkit-transition-delay: 2s; /* Safari */
transition-delay: 2s;
Here is a list of some timing-functions you can use for transitions - http://www.w3schools.com/cssref/css3_pr_transition-timing-function.asp
Here is a fiddle to show you how the border-color transition takes .5 seconds to start on hover.
This will work only once while CSS being loaded if this id overwrites preceding or default rules. You might not even noticed it.
Once CSS is loaded, it remains in your browsers and nothing will happen anymore.
You may give a try to link your CSS file with a time stamp to force refreshing CSS each time you reload a page. kind of like /myCssFile.css&id=010012014
Actually, the good practise would be to add a class on onload event and set your transition or animation from there.
CSS is not really meant to do this.
Here is a test i made a while ago : http://codepen.io/gcyrillus/pen/rmhAp You may see an animation the very first time your browser will load it.
Mabye This Will Help
This continually changes the background color.
I have a Ul tag on hover of it, I display a div using css.
Now i want that div tag will 1st fadein or any other effect like animate etc.
I know it can be done easily by using jQuery, but want to know can i achieve this using Html5,css3,css
Here JsFiddle
Fading in http://jsfiddle.net/thebabydino/Cedue/7/
There was never anything like -webkit-opacity or -moz-opacity
If you want to transition the opacity, then either write
transition: opacity 1s
or
transition: 1s
From what I can tell, removing the display: none; and display: block; lines from your code enables animation:
http://jsfiddle.net/Cedue/31/
(That is a copy of your original fiddle with only the display: lines removed.) However, this raises the issue that you can access, highlight, and even hover the text when it's hidden; if you do not wish to have that behavior you might wish to look into another means of hiding it until the correct area is hovered, such as shifting it with margins.
As Ana has mentioned, as well, if you wish to animate the entire fade you should use opacity as your transition parameter (e.g.: transition: opacity 1s ease;, with the additional lines for separate browser support). If you use background as the transition property as you do in your example, only the background fades and the text appears instantly.
EDIT: due to my own curiosity I tested this under Chrome and Firefox, each for both Windows and Mac, and can confirm that removing the display lines caused the animation to work on all of them.
Check this site, it uses css and javascript.
Pure CSS implementation here.
You should look into CSS3 transitions http://www.alistapart.com/articles/understanding-css3-transitions/
I am working on a catalog which uses css -transform attribute to scale each 'swatch' upon hovering.
Here's my problem: In some browsers and on certain sites, when you hover over the swatches, it causes the page to 'blink' as your roll over them. I cannot nail the problem down either, on one site it may be unique to Safari, on another it may only happen in Chrome, on another it's perfectly fine.
Wish I had more information, but maybe someone else has run into a similar problem.
.swatch {
-webkit-box-shadow: #EFEFEF 2px 2px 0px;
-webkit-transform: scale(1);
-webkit-transition-duration: 0.2s;
border: 1px solid white;
position: relative;
z-index: 1;
.swatch:hover {
position:relative;
z-index:10;
transition-duration: 0.2s;
transform:scale(1.8);
-webkit-transition-duration: 0.2s;
-webkit-transform:scale(1.8);
}
It also seems that the problem is remedied when removing any z-index attributes, but then the hover swatch is behind the other swatches; which does not work for this project.
Any thoughts are appreciated.
I've had success adding
-webkit-backface-visibility: hidden;
to the offending element (.swatch in your case).
However, test it in older versions of Chrome and Safari to make sure it doesn't break anything else. In my experience, Safari 4 specifically isn't a big fan.
I had the same problem at this morning. But I found an answer on the web few moments ago.
To prevent the Blink issue, put the follow property on your .swatch class (not on :hover):
-webkit-transform-style: preserve-3d;
Try changing position:relative to position:absolute, and/or specify position attributes (top: x, left: y.
No idea if it will work, just throwing it out there.
when mouse over the images(img:hover) in chrome works fine. you can use like this
.swatch img:hover
http://dinolatoga.com/2009/09/18/amazing-imag-hover-effects-with-webkit-and-css/
I had the same problem try using opacity instead of z-index
img:hover{
opacity: 0;
}
On a different subject, I had the same effect (the awfull blink).
However, it wasn't on hover principles. It was on a dragable area, I wanted as smooth as possible on iPad. The area was originally moved with a css margin-left property.
Then, I used -webkit-transform':'translate3d(X, Y, Z)' for the smooth rendering, which is the case.
BUT, the use of translated3d made the famous blink, on the first drag (on iPad only).
Thanks to Fábio ZC, the -webkit-transform-style: preserve-3d; worked perfectly to get rid of the blink
For those who wants to know more about the -webkit-transform-style: preserve-3d and what is involved.
Back to the original problem, these are my thoughts:
You mention Safari & Chrome (so, webkit). Is the problem only on those browser? Which would lead to -webkit suspicious properties.
If so, -webkit-backface-visibility: hidden; or -webkit-transform-style: preserve-3d; are still good candidates to be tried:
Did you attach them on the .swatch class? (not hover state, otherwise, they will be considered too late, as the animation will be played directly)
You stated that the whole page is blinking? Strange as only the swatches should be impacted.
I deleted this line from the hovering class:
"display: none;" and amazingly, that worked. Try it and hope it solves your problem.
First of all, I've looked at this previous question but sadly it didn't seem to offer any solutions (other than JS which is a non-starter I'm afraid)
I've got some skip links at the top of my page...
<ul>
<li class="skip-link"><span>Skip to main content</span></li>
<li class="skip-link"><span>Skip to main navigation</span></li>
</ul>
and further down there is...
<div id="mainContent"></div>
which is an empty div purely there to act as an anchor point.
Everything seems to work fine when the link is activated; visually the page jumps down, and focus shifts to the first link after #mainContent.
However in Chrome (v 12.0.742.91), whilst the page visually shifts down, the focus does not, meaning that after activating the accesskey, tabbing again merely jumps you back up to the top of the page and back into the access links.
I had an identical issue with IE which was put down to a known quirk and was fixed by setting a specific width to the target element. However, that doesn't seem to work for Chrome. I have also tried adding a tab-able element into #mainContent div, putting any sort of content in the #mainContent div, as well as all sorts of float/width/height variations and nothing seems to fix it.
Has anyone had any similar issues with Chrome or knows a fix?
Thanks in advance folks
Simon
The best you can do until someone find a trick/hack is starring this issue which succeeded this one.
Your SO fellows will probably do the same because they care.
Apparently, it has finally been fixed.
I know this is an old question, but I finally stumbled across it today after searching for hours. I still haven't found a non-js solution to this, and though the issue is marked as fixed in Chrome, it still exhibits the same behavior. For a lack of anything else, I used jQuery. Rather than an inline script, I used an unobtrusive event listener.
The HTML:
<div id="skiptocontent">
Skip to Main Content
</div>
<div id="mainContent"></div>
The jQuery:
$(document).ready(function () {
$("#skipper").click(function () {
$('#mainContent').attr('tabIndex', -1).focus();
});
});
I also hide the link unless it receives focus from the keyboard. That way only keyboard users and screen readers will ever know the link is there. Using CSS3, you can ensure that it becomes briefly visible if a user tabs rapidly past it.
The CSS:
#skiptocontent a {
position: absolute;
top:-40px;
left:0px;
background:transparent;
-webkit-transition: top 1s ease-out, background 1s linear;
transition: top 1s ease-out, background 1s linear;
z-index: 100
}
#skiptocontent a:focus {
position:absolute;
left:0px;
top:0px;
background:#F1B82D;
-webkit-transition: top .1s ease-in, background .5s linear;
transition: top .1s ease-in, background .5s linear
}
For a demonstration, you can view the fiddle. If anyone has a way around the use of javascript, I would love to hear it. I don't think a solution is truly accessible if it requires js.
I came across this issue too and the only way I could find to fix it was with JavaScript (and jQuery).
So on the link I used an onClick $('#mainContent').attr('tabIndex',-1).focus();
"Adding the tabindex value of -1 to the div makes that div
programmatically focusable, allowing it to take the focus when the
.focus() method is used." -- Via: http://webstandardssherpa.com/reviews/overlays-and-lightboxes-keys-to-success/
See the fiddle:
http://jsfiddle.net/PEDaS/1/
Took the snippets above and tried generalizing them to target any potential skip link.
jQuery('[href^="#"][href!="#"]').click(function() {
jQuery(jQuery(this).attr('href')).attr('tabIndex', -1).focus();
});