Transition color fade on hover?
What do you want to fade? The background
or color
attribute?
Currently you're changing the background color, but telling it to transition the color property. You can use all
to transition all properties.
.clicker {
-moz-transition: all .2s ease-in;
-o-transition: all .2s ease-in;
-webkit-transition: all .2s ease-in;
transition: all .2s ease-in;
background: #f5f5f5;
padding: 20px;
}
.clicker:hover {
background: #eee;
}
Otherwise just use transition: background .2s ease-in
.
CSS animation, fade in background on hover, stay, and go back to previous after a delay
I think you may have complicated things by using animation
when a transition
would have been the better option. Animations have a start and end point (the 0%
and 100%
keyframes) so when you hover-in or out, the element is first set to the state as at the 0%
keyframe (since animation direction is normal) and then proceeds to the 100%
keyframe. When you hover-in or out quickly (before previous animation is complete) you'd always see these jumps because of the setting of 0%
keyframe's props.
The below should be what you need:
div { width: 100px; height: 100px; background: rgba(50, 60, 95, 0.3); transition-property: background; transition-duration: 1s; transition-delay: 2s;}div:hover { background: rgba(50, 60, 95, 1); transition-delay: 0s;}
<div></div>
CSS: Color fades in on hover but I cant get it to fade away when the mouse moves away
You want to apply the transition
to .card
directly, not the :hover
:
.card { -webkit-transition: background-color .3s; transition: background-color .3s;}
.card:hover { background-color: #12455a; color: #fff;}
<div class="hacker col-xl-6 col-md-6 mb-4"> <a href="http://text.com/filler/"> <div class="card card-body border-0 shadow"> <img src="img/filler.png" class="card-img-top" alt="Filler"> <div class="card-body text-center"> <h5 class="title1 mb-0">Filler</h5> <div class="subtitle ">Web Design</div> </div> </div> </a></div>
Fade Effect on Link Hover?
Nowadays people are just using CSS3 transitions because it's a lot easier than messing with JS, browser support is reasonably good and it's merely cosmetic so it doesn't matter if it doesn't work.
Something like this gets the job done:
a {
color:blue;
/* First we need to help some browsers along for this to work.
Just because a vendor prefix is there, doesn't mean it will
work in a browser made by that vendor either, it's just for
future-proofing purposes I guess. */
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
/* ...and now for the proper property */
transition:.5s;
}
a:hover { color:red; }
You can also transition specific CSS properties with different timings and easing functions by separating each declaration with a comma, like so:
a {
color:blue; background:white;
-o-transition:color .2s ease-out, background 1s ease-in;
-ms-transition:color .2s ease-out, background 1s ease-in;
-moz-transition:color .2s ease-out, background 1s ease-in;
-webkit-transition:color .2s ease-out, background 1s ease-in;
/* ...and now override with proper CSS property */
transition:color .2s ease-out, background 1s ease-in;
}
a:hover { color:red; background:yellow; }
Demo here
fadein background color on hover using CSS
You need to use transition
property
.block {
width: 200px;
height: 200px;
border: 1px solid #333;
-webkit-transition: background .5s; /* For webkits */
transition: background .5s;
}
Demo
The property is simple, the first parameter you pass is the property you want to animate, so say you want to animate the height
you can pass the height
or you can use all
as the value if you want to transit all the properties which are transitional, and the next parameter is the time we set for the transition, you can set as 1s
, 2s
and so on where S
stands for seconds.
It's worth noting that the property am using is a short hand property for the following properties
transition-delay: 0s
transition-duration: 0s
transition-property: background
transition-timing-function: ease
Where in the above example we are using the transition-property
and transition-duration
, default values are used for other properties.
Hover page background change color fade effect (css or jQuery)
background-color is a CSS transitionable/animatable property.
All I did was set the transition, and used JQuery to add/remove some classes causing the background color of that element to change.
Have a look at my CodePen here:
http://codepen.io/jarodsmk/pen/EyAOdN
HTML:
<body>
<h1>Mouse over a color</h1>
</br>
<div class="blue">Blue</div>
<div class="green">Green</div>
</body>
CSS:
body{
background-color: red;
transition: background-color 4s;
}
.blue,body.blue{
background-color: blue;
}
.green,body.green{
background-color: green;
}
JS:
$('.blue').hover(function(){
$('body').addClass('blue');
}, function(){
$('body').removeClass('blue');
});
$('.green').hover(function(){
$('body').addClass('green');
}, function(){
$('body').removeClass('green');
});
How can I make an image fade into color upon hover?
YES, this is possible... But not in the traditional sense.
In order to accomplish this, you'll need to forgo <img />
, and instead make use of two images presented with content: url()
in :before
and :after
pseudo-classes. Set the :before
to be your starting image, and :after
to be your target image. Then set the opacity
of :after
to 0
by default, and set the two pseudo-elements to sit on top of one another. Finally, set a :hover
rule for both :before
and :after
which toggles their opacity
, and use transition: opacity
to control the fade.
This can be seen in the following:
* { margin: 0;}
.image:before { content: url("https://via.placeholder.com/150/FF0000/00FFFF"); transition: opacity 0.5s ease; -webkit-transition: opacity 0.5s ease;}
.image:after { position: absolute; left: 0; opacity: 0; content: url("https://via.placeholder.com/150/00FFFF/FF0000"); transition: opacity 0.5s ease; -webkit-transition: opacity 0.5s ease;}
.image:hover:after { opacity: 1;}
.image:hover:before { opacity: 0;}
<div class="image"></div>
Fade in border on hover
When an element has no border, then you add on hover you face a few issues such as page moving, drawing border from scratch etc
Solution: Try setting border to transparent first, so it's there but cannot be seen:
a { border-bottom: 2px solid transparent; /* <- here */ transition: border-bottom 1s; text-decoration: none; /* I added this for clarity of effect */}a:hover { border-bottom: 2px solid red;}
<a href="">testing border</a>
CSS - smooth button gradient color transition on hover
Short answer, you can't using just background. However, you can achieve a similar effect using other elements (or pseudo elements) inside and fading them in on hover.
The following example uses two pseudo-elements as the two background states. On hover, we simply fade-in the new background giving a similar transition effect that would happen if gradients were transition-able.
NOTE: Not all browsers support transitions on pseudo elements, so you may need to add empty elements to achieve the same effect on older/unsupported browsers.
.cta-btn { position: relative; display: inline-block; margin: 20px 0 0 20px; color: #fff; box-shadow: 4px 5px 27px 4px rgba(220, 120, 184, 0.85); font-size: 21px; border-radius: 30px; overflow: hidden; padding: 12px 21px; font-family: Montserrat; transition: box-shadow.3s ease-in-out; text-decoration: none;}
/* These are the two backgrounds, absolutely positioned to cover. */.cta-btn::before,.cta-btn::after { content: ''; display: block; position: absolute; left: 0; top: 0; bottom: 0; right: 0; background-image: linear-gradient(to right, #2ab3ff, #ff2d00); border-radius: 30px; z-index: -1;}
.cta-btn::after { opacity: 0; background-image: linear-gradient(to right,#FF2A67,#FF5D3A); transition: opacity.3s ease-in-out;}
/* On hover, transtiion the shadow of the anchor, and fade in the after element to show the new background. */.cta-btn:hover { box-shadow: 4px 5px 27px 4px rgba(255,45,45,0.85);}.cta-btn:hover::after { opacity: 1;}
<a href="#" class="cta-btn">click me</a>
Related Topics
Differencebetween Bootstrap.CSS and Bootstrap-Theme.Css
Styling Qml Without Manually Marking Each Property to Be Styled
Responsive Design - Media Query Not Working on Iphone
CSS Relative + Right (Or Bottom) Almost Never Work
Which CSS Selector Is Stronger
Angular Material - Global Color Variables
Css3 Gradients to Reproduce an 'Inner Glow' Effect from Illustrator with Border-Radius Applied
CSS Selector Clarification: |= VS ^=
Angular - Including CSS File in Index.Html
Can Text Be Hidden and Shown Using Just CSS (No JavaScript Code)
Bootstrap 3 Navbar Active Li Not Changing Background-Color
Using Ie Conditional Comments Inside a Stylesheet
Linear Gradient in Chrome and Safari Browsers
How to Set Selected and Hover Color of Listitem in Mui
How to Add Custom CSS in Wix Website