fade out everything but hovered link is not working in Chrome - html

I use this hover-effect, where everything but the hovered Element fades out, you can see it in the snippet below.
Its working in Firefox (Version 66.0.3 ) but not in Chrome (Version 73.0.3683.103). I also tried Microsoft Edge, it works there aswell.
I tried adding "-webkit-" because I read, that this could fix the problem, but it didn´t.
Anybody an idea how to achieve this hover-effect in Chrome?
.links{
font-weight: bold;
font-size: 20px;
}
/* Hover Effect */
.hover {
visibility: hidden;
}
.hover > * {
visibility: visible;
transition: opacity 100ms linear 100ms;
}
.hover:hover > * {
opacity: 0.3;
}
.hover > *:hover {
opacity: 1;
transition-delay: 0ms, 0ms;
}
EDIT:
It works in Chrome, if I remove the links (in my case references to other pages of the website).
Working in Chrome:
.links {
font-weight: bold;
font-size: 20px;
}
/* Hover Effect */
.hover {
visibility: hidden;
}
.hover>* {
visibility: visible;
transition: opacity 100ms linear 100ms;
}
.hover:hover>* {
opacity: 0.3;
}
.hover>*:hover {
opacity: 1;
transition-delay: 0ms, 0ms;
}
<div class="links">
<div class="hover">
<div class="linkNav">1</div>
<div class="linkNav">2</div>
<div class="linkNav">3</div>
</div>
</div>
Not Working in Chrome:
.links {
font-weight: bold;
font-size: 20px;
}
/* Hover Effect */
.hover {
visibility: hidden;
}
.hover>* {
visibility: visible;
transition: opacity 100ms linear 100ms;
}
.hover:hover>* {
opacity: 0.3;
}
.hover>*:hover {
opacity: 1;
transition-delay: 0ms, 0ms;
}
<div class="links">
<div class="hover">
<a href="1.html">
<div class="linkNav">1</div>
</a>
<a href="2.html">
<div class="linkNav">2</div>
</a>
<a href="3.html">
<div class="linkNav">3</div>
</a>
</div>
</div>

(N.b. I have updated this answer after noting the problem with the HTML).
I simplified your CSS to try and isolate the problem (I removed the visibility properties that aren't doing anything as well as the > * selectors)
It's unsurprising there is unpredictable behaviour in this case because strictly speaking you shouldn't be putting a block level element such as <div> inside an <a> element.
It seems that, in this case of malformed HTML, Chrome won't recognise the opacity value of the anchor (<a>) tag unless I do something like set it to display: block or display:inline-block. FireFox, Edge and IE do recognise the opacity regardless.
The best solution would be to fix your HTML so that the block level elements wrap the inline elements properly.
.links {
font-weight: bold;
font-size: 20px;
}
.hover:hover a {
opacity: 0.3;
}
.hover a:hover {
opacity: 1;
}
<div class="links hover">
<div class="linkNav">1</div>
<div class="linkNav">2</div>
<div class="linkNav">3</div>
</div>
I would recommend fixing it like this but if for some reason you can't fix the HTM a workaround is to set the display property on your anchor tags. Like so:
.links {
font-weight: bold;
font-size: 20px;
}
.links a {
display:block;
}
.hover:hover a {
opacity: 0.3;
}
.hover a:hover {
opacity: 1;
}
<div class="links hover">
<div class="linkNav">1</div>
<div class="linkNav">2</div>
<div class="linkNav">3</div>
</div>
Or else an alternative solution is you could simply target an alternative element, such as the inner div instead of the a tag.
JSFiddle links for the different workaround solutions and the original CVE that demonstrates the issue (useful for testing in different browsers):
Solution by setting display block
Solution by changing selector to target inner div
Original CVE which works in most browsers but not Chrome

I have corrected the code
the problem here was in the ordering you were adding HTML
The a tag has div inside it and class on that which the selector on hover was unable to reach to.
Now see, it works fine.
This is it I guess.
Hope it solves your problem.
.links {
font-weight: bold;
font-size: 20px;
}
/* Hover Effect */
.hover {
visibility: hidden;
}
.hover>* {
visibility: visible;
transition: opacity 100ms linear 100ms;
}
.hover:hover>* {
opacity: 0.3;
}
.hover>*:hover {
opacity: 1;
transition-delay: 0ms, 0ms;
}
<div class="links">
<div class="hover">
1
2
3
</div>
</div>

Related

Make only link-text clickable on hover

I am currently trying to make a h1 link that transforms when hovering over it. This works perfectly, when placing the /a outside of h1 However, doing this resolves in making the whole element react and clickable when hovering over it - it just looks bad. Placing /a inside /h1 makes only the text clickable as desired - yet it doesn't react to hover, but to all other changes it does.
Please note that I am a beginner and I do not know what exact context is required for you to help me.
This lets hover work, but makes the whole element clickable.
#headlines a:hover {
transform: scale(1.5);
transition: 0.1s;
}
<div class="grid_6" style="color: black; text-align: center">
<a href="headlines.html"
id="headlines"
style="text-decoration: none; color: black">
<h1> Headlines
</h1></a>
<hr>
</div>
Apply transform to the h1 on hover...but make the h1 as display:inline-block so it's no bigger than it needs to be.
The link will always be clickable but it should solve the sizing issue.
a#headlines h1 {
display: inline-block;
}
a#headlines h1 {
transition: transform .5s ease;
}
a#headlines h1:hover {
transform: scale(1.5);
}
<div class="grid_6" style="color: black; text-align: center">
<a href="headlines.html" id="headlines" style="text-decoration: none; color: black">
<h1> Headlines
</h1>
</a>
<hr>
</div>
you can try it
a#headlines:hover {
transition: transform .5s ease;
transform: scale(1.5);
}
Just add this:
a {
font-weight: bold;
font-size: 45px;
transition: all 500ms;
}
a:hover {
font-size:60px;
font-size-adjust: 20px;
}
This is the Fiddle

Adding animation to content property, after hovering

What I am trying to achieve is an animation when you hover an element like this:
#import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
.home:hover::after{
content: " Home";
}
<i class="fa fa-home"></i>
So when you hover the a, some additional text will be display, but I couldn't find any transition for smooth showing it. Don't mind answering to use transition: all ..., because this isn't working. Live example of the website can be found at http://www.testingc.ga or in the snippet below.
iframe snippet (Open the navigation to see the elements with the content: "Text" on hover.
iframe{
border: none;
width: 100vw;
height: 100vh;
}
<iframe src="https://www.tc.gamingprouk.net">Error</iframe>
Any help would be welcome!
Something like this?
I made a fade-in / fade-out effect with a CSS transition
.home {
position: relative;
}
.home::after {
content: 'Home';
transition: opacity 0.5s;
opacity: 0;
pointer-events: none;
position: absolute;
margin-left: 10px;
}
.home:hover::after {
opacity: 1;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<i class="fa fa-home"></i>
You could set the original state first then animate it on hover
a:after {
content: 'Home';
opacity: 0;
transition: opacity: 0.5s linear;
}
a:hover:after {
opacity: 1;
}

How can I apply transitions to my elements that have display:none?

I have some divs that appear when you hover an image. However, I want to have a transition rather than the images appearing so abruptly. I'm trying to avoid javascript if possible.
img {
display: none
}
p.one:hover + img {
display: block;
}
p.two:hover img {
display: block;
}
http://jsfiddle.net/nmeyf03r/56/
Transitions don't work with display: none. You can't fade in an element that's been removed from the page. Similarly, you can't fade out a display: block element. With display, the element is either in or out.
However, you can still transition your divs with CSS using the visibility, opacity and height properties.
HTML
<p class="one">HOVER OVER ME - IMG IS SIBLING</p>
<img src="http://www.placecage.com/100/100">
<p class="two">HOVER OVER ME -IMG IS CHILD</p>
<img src="http://www.placecage.com/100/100">
CSS
img {
visibility: hidden;
opacity: 0;
height: 0;
transition: height .5s linear, opacity .5s linear;
}
p.one:hover + img {
visibility: visible;
opacity: 1;
height: 100px;
transition-delay: 0s;
}
p.two:hover + img {
visibility: visible;
opacity: 1;
height: 100px;
transition-delay: 0s;
}
Here's your demo, updated with the code above:
http://jsfiddle.net/nmeyf03r/58/

Opacity when hovering DIV or other Element

I want to apply opacity: 1; to a Paragraph when hovering over itself (I have figured that out) and when I hover the header above it.
This is my CSS
.testH {
font-family: impact;
text-align: center;
font-size: 50px;
transition: all 1s;
}
.testP {
text-align: center;
opacity: 0.5;
font-size: 18px;
transition: all 1s;
}
#testHdiv:hover {
opacity: 1;
}
.testP:hover {
opacity: 1;
}
My HTML
<div id="testHdiv"><h1 class="testH"><b>< ></b></h1>
<p class="testP">Text and text, more text<br>Bla bla bla bla</p>
</div>
So, as you can see I try to get the opacity from the paragraphs current 0.5, to 1 when hovering the Div - my idea is: being able to hover a "box"/the div, and the text becomming less transparent. Though I think the opacity on the hover of the Div does not Work as the div is defined a Div, not text, and therefor can't be transparent?
I have been struggling with this for a while now. But I am basically wanting something like this: http://demo.web3canvas.com/themeforest/flathost/onepage/index.html#testimonials, where you hover within range of the text and it is being zoomed - in this case, just with opacity.
You can set a class to the <p> or just, use an operator to set the :hover to paragraph.
Example:
#testHdiv:hover > p {
opacity: 1;
}
http://jsfiddle.net/g97pusex/1/
Just change this:
#testHdiv:hover {
opacity: 1;
}
To be like that:
#testHdiv:hover p{
opacity: 1;
}
You'll want to apply the opacity to the p element, not the div. According to your provided style, you can change it to this:
.testH {
font-family: impact;
text-align: center;
font-size: 50px;
transition: all 1s;
}
.testP {
text-align: center;
opacity: 0.5;
font-size: 18px;
transition: all 1s;
}
#testHdiv:hover .testH {
opacity: 1;
}
#testHdiv:hover .testP {
opacity: 1;
}
Notice how the :hover selector is applied to the div, but the style is applied to the p element .testP
If you are trying to hover the div and on hover it affect the paragraph opacity change your CSS to:
#testHdiv:hover .testP{
opacity: 1;
}

Angular animate ng-cloak opacity

I cannot seem to animate ng-cloak. Essentially, I'm trying to animate a div from .containter.ng-cloak to .container.ng-binding
But it doesn't seem to work—Angular loads the div with container ng-binding classes straight away, ignoring the transition rule.
I even tried using transition-delay set to a couple seconds, no dice.
HTML
<div class="container ng-cloak" ng-controller="AppCtrl">
CSS
.container.ng-cloak,
.container.ng-binding {
opacity: 0;
transition: opacity 800ms ease-in-out;
}
.container.ng-binding {
opacity: 1;
}
Worth noting:
transitioning background-color from blue to red seemed to work as expected.
I omitted vendor-prefixes for the sake of brevity.
Thanks in advance.
A different approach:
http://jsfiddle.net/coma/UxcxP/2/
HTML
<section ng-app>
<div ng-class="{foo:true}"></div>
</section>
CSS
div {
width: 100px;
height: 100px;
background-color: red;
opacity: 0;
-moz-transition: opacity 0.5s ease;
-o-transition: opacity 0.5s ease;
-webkit-transition: opacity 0.5s ease;
transition: opacity 0.5s ease;
}
div.foo {
opacity: 1;
}
This will work like cloak since Angular won't set the foo class until is loaded.
The cloak won't work as you want because it'll be there (as a class, attribute, element...) until Angular replace it with the result of its templating process, so it isn't the same node and that's why it won't get the transition (a transition occurs when the same element changes), is not changing, is just not the same node.
Take a look at this:
http://jsfiddle.net/coma/UxcxP/5/
As you can see in that example, the div next to the one being "angularized" is getting the fade animation because it's the same div even before Angular taking place.
I realize there's been an accepted answer; however this is doable with the ng-cloak directive as originally attempted.
I use it to animate Jade generated markup. Your Mileage May Vary with Angular runtime-templated markup.
http://codepen.io/simshanith/pen/mqCad
HTML
<div class="container ng-cloak fade-ng-cloak" ng-controller="AppCtrl">
CSS
[ng\:cloak],
[ng-cloak],
[data-ng-cloak],
[x-ng-cloak],
.ng-cloak,
.x-ng-cloak {
display: none !important;
}
.fade-ng-cloak {
opacity: 1;
-ms-filter: none;
-webkit-filter: none;
filter: none;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.fade-ng-cloak[ng-cloak] {
display: block !important;
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
}
.fade-ng-cloak.ng-cloak,
.fade-ng-cloak.ng-binding {
opacity: 0;
transition: opacity 800ms ease-in-out;
}
.fade-ng-cloak.ng-binding {
opacity: 1;
}
A pure CSS solution without adding extra-classes to the HTML:
HTML
<div ng-cloak>{{myProperty}}</div>
CSS
[ng-cloak] {
display: block !important;
opacity: 0;
}
[ng-cloak],
.ng-binding {
transition: opacity 300ms ease-in-out;
}
.ng-binding {
opacity: 1;
}
My solution is similar to some of the others, but my use case required that I use cloak on a div that angular doesn't bind to, so this is what I ended up doing...
(browser prefixes omitted for brevity)
CSS
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak{
display: none !important;
}
.fade-ng-cloak {
display: block !important;
opacity: 1;
transition: opacity 0.5s;
}
.fade-ng-cloak.ng-cloak {
opacity: 0;
}
HTML
<div class="row ng-cloak fade-ng-cloak">
<div class="col-xs-12">
<uib-accordion close-others="true">
...
</uib-accordion>
</div>
</div>