The problem is basically that the class that transitions ( .img-fader
) using fadeOut
and fadeIn
is in body
, so all content will be affected.
One solution is to put form
out of div container
and apply the .img-fader
class to this div
. As a result, form
will not be affected.
It is also necessary to change the CSS of form
so that it stays centered on the screen, and adjust height height
of div container
to occupy the entire screen.
Also replace the class container
with container-fluid
, which will occupy the full width of the screen.
HTML will look like this:
Do not forget to delete the class img-fader
from <body>
.
<div class="container-fluid img-fader">
</div>
<form class="login-form" method="post" action="https://weec-sistemas.000webhostapp.com/sistema-teste/login.php">
<div class="login-wrap">
<p class="login-img"><i class="fa fa-lock" aria-hidden="true"></i></p>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user" aria-hidden="true"></i></span>
<input type="text" id="loginUsuario" name="loginUsuario" class="form-control" placeholder="Usuário" autofocus>
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock" aria-hidden="true"></i></span>
<input type="password" id="senhaUsuario" name="senhaUsuario" class="form-control" placeholder="Senha">
</div>
<label class="checkbox">
<input type="checkbox" value="lembra-me"> Lembrar me
<span class="pull-right"> <a href="https://weec-sistemas.000webhostapp.com/sistema-teste/login.php#"> Esqueceu senha?</a></span>
</label>
<input type="submit" name="logar" value="Login" class="btn btn-primary btn-lg btn-block" data-disable-with="Login">
<!-- <button class="btn btn-info btn-lg btn-block" type="submit">Signup</button> -->
</div>
</form>
CSS Changes
Change the .login-form
class in your CSS below by this, it will center the form on the screen:
.login-form {
max-width: 350px;
background: #d5d7de, fixed;
position: fixed;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
}
Finally, include the following code in your img-slider.js
file at the beginning of $(document).ready(function(){
:
$(window).on("load resize", function(){
$(".container-fluid").css("height",window.innerHeight+"px");
});
Looking like this:
$(document).ready(function(){
$(window).on("load resize", function(){
$(".container-fluid").css("height",window.innerHeight+"px");
});
var count = 0;
var images = ["img/bg-1.jpg","img/bg-2.jpg","img/bg-3.jpg"];
var image = $(".img-fader");
image.css("background-image","url("+images[count]+")");
setInterval(function(){
image.fadeOut(500, function(){
image.css("background-image","url("+images[count++]+")");
image.fadeIn(500);
});
if(count == images.length)
{
count = 0;
}
},5000);
});
See working here.