Jump to content

Recommended Posts

I somehow got hooked on a stylish form that was broken into stages that click thru three steps.

It uses CSS and hidden checkboxes to activate an effect that has each section transition into a visible opacity (a fade-in effect).

I was hoping to use the code as a template, but discovered that the FIRST page (which does not have an associated checkbox in the HTML) does not at any point "fade-in" (it just remains visible).

This makes the entire form seem 'clumsy' bc the effect should occur with NEXT or PREVIOUS button clicks.

I've included the pertinent code.

I'm also not sure of whether or not using CSS is the best route for this. I'm sure JavaScript can do this; is one approach better than the other?

Thanks.

input[type=checkbox] {
	position: absolute;
	opacity: 0;
}
#part1, #part2, #part3 {
	z-index: 2;
	display: block;
	height: auto;
	opacity: 1;
	transition: opacity 1s ease-in-out;
}
#part2, #part3 {
	opacity: 0;
	height: 0;
	overflow: hidden;
}
#step2:checked ~ #part2 {
	opacity: 1;
	height: auto;
}
#step2:checked ~ #part1 {
	opacity: 0;
	height: 0;
	display: none;
}
#step3:checked ~ #part3 {
	opacity: 1;
	height: auto;
}
#step3:checked ~ #part2 {
	opacity: 0;
	width: 0;
	height: 0;
}

 

 

Edited by phppup
Link to comment
https://forums.phpfreaks.com/topic/318939-transition-fade-in-effect/
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.