Hello. There was such a question. How can I implement a smooth transition of images (background) on pure Javascript? Thank you in advance
The question is still valid.
Hello. There was such a question. How can I implement a smooth transition of images (background) on pure Javascript? Thank you in advance
The question is still valid.
Faced with a similar problem. Made myself a Majesty 2 fan site . There, I just had to have a self-titled div, and I was confused to make it transparent without pictures. In general, I think that without a fake-substrate, that is, without a diva, which will be positioned under the background of the site, can not do. Well, there already is opacity.
You can, of course, create a transition between backgrounds by changing monochromatic or gradient pictures with different transparency, and put them on a container of your level so that the current background is shaded.
Hmm, I'm afraid without shamanism can not do. The first thing that comes to mind:
position:relative;
), for the entire parent element (the very whose background we want to smoothly change);Thus we get a smooth change, and the most culminating moment - are these beautiful things worth it? :)
In pure JavaScript this is not hard to implement. But it's pretty easy to do using CSS . Do not forget that styles are needed for that. If you correctly make a preliminary markup, then the background property, and this is your background, can be added to the html element:
html { background: url(picture.png); }
Now you have two html and body blocks with images that overlap (if you set the margin and padding correctly for the body element) on each other. Skillful management of opacity properties gives you the desired effect.
A bunch of ready-made options On pure css it is impossible to do, but on JS completely.
Source: https://ru.stackoverflow.com/questions/21288/
All Articles