var current_fs, next_fs, previous_fs;
var left, opacity, scale;
var animating;
$(".next").click(function() {
if (animating) return false;
animating = true;
current_fs = $(this).parent();
if ($(this).attr('name') == 'feveryes')
next_fs = $('#feveryes');
if ($(this).attr('name') == 'feverno')
next_fs = $('#feverno');
if ($(this).attr('name') == 'coughyes')
next_fs = $('#coughyes');
if ($(this).attr('name') == 'coughno')
next_fs = $('#coughno');
if ($(this).attr('name') == 'previous')
next_fs = $('#firstField');
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
next_fs.show();
current_fs.animate({
opacity: 0
}, {
step: function(now, mx) {
scale = 1 - (1 - now) * 0.2;
left = (now * 50) + "%";
opacity = 1 - now;
next_fs.css({
'left': left,
'opacity': opacity
});
},
duration: 800,
complete: function() {
current_fs.hide();
animating = false;
},
easing: 'easeInOutBack'
});
});
$(".previous").click(function() {
if (animating) return false;
animating = true;
current_fs = $(this).parent();
previous_fs = $('#firstField');
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
previous_fs.show();
current_fs.animate({
opacity: 0
}, {
step: function(now, mx) {
scale = 0.8 + (1 - now) * 0.2;
left = ((1 - now) * 50) + "%";
opacity = 1 - now;
current_fs.css({
'left': left
});
previous_fs.css({
'transform': 'scale(' + scale + ')',
'opacity': opacity
});
},
duration: 800,
complete: function() {
current_fs.hide();
animating = false;
},
easing: 'easeInOutBack'
});
});
$(".submit").click(function() {
return false;
});
@import url(http://fonts.googleapis.com/css?family=Montserrat);
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
background: url('http://thecodeplayer.com/uploads/media/gs.png');
background: linear-gradient(rgba(196, 102, 0, 0.2), rgba(155, 89, 182, 0.2)), url('http://thecodeplayer.com/uploads/media/gs.png');
}
body {
font-family: montserrat, arial, verdana;
overflow-x: hidden;
}
#msform {
width: 100%;
margin: 50px auto;
text-align: center;
position: relative;
}
#msform fieldset {
background: white;
border: 0 none;
border-radius: 3px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;
box-sizing: border-box;
width: 80%;
margin: 0 10%;
position: absolute;
}
#msform fieldset:not(:first-of-type) {
display: none;
}
#msform img {
width: 80%;
}
#msform input,
#msform textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
#msform .action-button {
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#msform .action-button:hover,
#msform .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}
.fs-title {
font-size: 15px;
text-transform: uppercase;
color: #2C3E50;
margin-bottom: 10px;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #666;
margin-bottom: 20px;
}
#progressbar {
margin-bottom: 30px;
overflow: hidden;
counter-reset: step;
}
#progressbar li {
list-style-type: none;
color: white;
text-transform: uppercase;
font-size: 9px;
width: 33.33%;
float: left;
position: relative;
}
#progressbar li:before {
content: counter(step);
counter-increment: step;
width: 20px;
line-height: 20px;
display: block;
font-size: 10px;
color: #333;
background: white;
border-radius: 3px;
margin: 0 auto 5px auto;
}
#progressbar li:after {
content: '';
width: 100%;
height: 2px;
background: white;
position: absolute;
left: -50%;
top: 9px;
z-index: -1;
}
#progressbar li:first-child:after {
content: none;
}
#progressbar li.active:before,
#progressbar li.active:after {
background: #27AE60;
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://thecodeplayer.com/uploads/js/jquery.easing.min.js"></script>
<form id="msform">
<fieldset id="firstField">
<h2 class="fs-title">Do yo have a fever?</h2>
<input type="button" name="feveryes" class="next action-button" value="Yes" />
<input type="button" name="feverno" class="next action-button" value="No" />
<br><input type="button" name="previous" class="previous action-button" value="Reset" />
</fieldset>
<fieldset id="feveryes">
<h2 class="fs-title">Do you have a cough? Do you have a cough? Do you have a cough? Do you have a cough? Do you have a cough? Do you have a cough? Do you have a cough? Do you have a cough? </h2><br><img src="https://upload.wikimedia.org/wikipedia/en/thumb/6/63/IMG_(business).svg/1280px-IMG_(business).svg.png">
<input type="button" name="coughyes" class="next action-button" value="Yes" />
<input type="button" name="coughno" class="next action-button" value="No" />
<br><input type="button" name="previous" class="previous action-button" value="Reset" />
</fieldset>
<fieldset id="coughyes">
<h2 class="fs-title">Go to Doctor!</h2>
<br><input type="button" name="previous" class="previous action-button" value="Reset" />
</fieldset>
<fieldset id="feverno">
<h2 class="fs-title">You are healthy!</h2>
<br><input type="button" name="previous" class="previous action-button" value="Reset" />
</fieldset>
<fieldset id="coughno">
<h2 class="fs-title">Be careful!</h2>
<br><input type="button" name="previous" class="previous action-button" value="Reset" />
</fieldset>
</form>
没有
- 你很健康!... 哈哈,好的。 - user7393973