我有一个容器(500px宽度和高度800px)。容器用户将图像作为背景,在中间我想添加一个“注册”的按钮。当用户点击注册按钮时,我想要一个弹出在同一容器中的注册表单。
换句话说,我需要一个翻转效果,其中背景颜色变为其他颜色,同一个容器用于注册框。我需要进行转换,直到用户点击关闭按钮或类似的东西。
我怎样才能做到这一点?任何想法将不胜感激。谢谢!
答案 0 :(得分:2)
您可以将2个容器放在彼此的顶部,淡入/淡出顶部容器 - DEMO
的 HTML 强> 的
<section>
<div id="lower">
<button> Close </button>
</div>
<div id="upper">
<button> Sign up </button>
</div>
</section>
的 CSS 强> 的
div {
position: absolute;
left: 20px;
top: 20px;
height: 300px;
width: 400px;
line-height: 300px;
text-align: center;
}
#lower { background: honeydew; }
#upper { background: beige; }
的的jQuery 强> 的
$("#upper button").on("click", function() {
$("#upper").fadeOut(300);
});
$("#lower button").on("click", function() {
$("#upper").fadeIn(300);
});