Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
717 views
in Technique[技术] by (71.8m points)

animation - CSS fade out transition between pages

I'd like to make a transition between two pages using only CSS.

I tried two solutions :

  1. Once we clic on the button I use the pseuo element "active" and I create a transition with the opacity of my .body (.full_width in my case) to make disappear the whole page.
.button {
&:active + .full_width {
opacity: 0;
transition: opacity 2s;
}
}

When I try this CSS without the condition it works perfectly, my page beautifully disappears. But when I put the "active" condition it's not working.

  1. I created a :after of my button with no content, but a background that takes the whole screen
.button::after {
    content:'';
    position: fixed;
    z-index: -10;
    top: 0;
    bottom: 0;
    right:0;
    left:0;
    width: 100%;
    opacity: 0;
    background-color: #DFE3E5;
    transition: opacity 2s;
} 

And then, when I activate the button, I change the z-index to bring the ::after in the foreground and change the opacity. The animation works perfectly once again, but my link doesn't work. It doesn't load the new page.

.button:active::after
{
    z-index: 1;
  opacity: 1;
}

Do you have any idea how to solve my issue ? I am so close it's very frustrating ^^

Thank you !

question from:https://stackoverflow.com/questions/65924129/css-fade-out-transition-between-pages

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...