Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transition fade in

So I have used CSS transitions before but I have a unique case with this one. I am writing a custom plugin for creating modals. Essentially I create a div on the fly document.createElement('div') and append it to the body with a few classes. These classes define color and opacity. I would like to use strictly CSS to be able to fade in this div, but making the state change seems difficult b/c they require some user interaction.

Tried some advanced selectors hoping it would case a state change, tried media query hoping to change state...looking for any ideas and suggestions, I really want to keep this in CSS if possible

like image 267
afreeland Avatar asked Jul 26 '12 00:07

afreeland


People also ask

How do I fade in and fade out in CSS?

The jQuery fadeToggle() method toggles between the fadeIn() and fadeOut() methods. If the elements are faded out, fadeToggle() will fade them in.

How do I fade text in CSS?

Use animation and transition property to create a fade-in effect on page load using CSS. Method 1: Using CSS animation property: A CSS animation is defined with 2 keyframes. One with the opacity set to 0, the other with the opacity set to 1.

How do I use webkit transition in CSS?

Use the @supports (transition) feature query instead. The -webkit-transition Boolean non-standardCSS media feature is a WebKit extension whose value is true if the browsing context supports CSS transitions. Apple has a description in Safari CSS Reference; this is now called transition there.


1 Answers

CSS Keyframes support is pretty good these days:

.fade-in {  	opacity: 1;  	animation-name: fadeInOpacity;  	animation-iteration-count: 1;  	animation-timing-function: ease-in;  	animation-duration: 2s;  }    @keyframes fadeInOpacity {  	0% {  		opacity: 0;  	}  	100% {  		opacity: 1;  	}  }
<h1 class="fade-in">Fade Me Down Scotty</h1>
like image 188
DigitalDesignDj Avatar answered Oct 04 '22 03:10

DigitalDesignDj