Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
bootstrap 4 login form placing it in the middle of the page ,im having a problem doing that >:(
HTML
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Login</title>
        <link rel="stylesheet" href="login.css">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">

      

</head>

<body style="background-color:#87CEEB ;>


  <div class="container">

    <div class="Absolute-Center is-Responsive">


          <div class="col-xs-3 col-sm-6 col-md-5 col-lg-4  col-xl-3 ">

       <form  align="align-items-center" id="form" class="form-signin " method="post">

         <div class="d-flex justify-content-center align-items-center" >
         <h2 id="heading" class="form-signin-heading"><strong>Please sign in</strong></h2>
        </div>

          <div class="form-group">
         <label for="email" class="sr-only">Email address</label>
         <input type="email"  id="email" class="form-control" placeholder="Email address" required autofocus>
         </div>

         <div class="form-group">
         <label for="password" class="sr-only">Password</label>
         <input type="password" id="password" class="form-control" placeholder="Password" required>
         </div>

         <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
       </form>

</div>

</div>

</div>


  <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</body>

</html>

CSS
.form-signin
{

    padding-top: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    padding-left: 20px;

    margin-top:280px;

    background-color:#F5F5F5;
    border: 1px solid rgba(0,0,0,0.1);
}

#heading
{
    padding-bottom: 20px;
}


What I have tried:

tried everything
Posted
Updated 8-Feb-18 5:11am
v2
Comments
Richard Deeming 8-Feb-18 11:08am    
Why are you still using BS4 Alpha 6, when the finished version was released in January?
https://blog.getbootstrap.com/2018/01/18/bootstrap-4/[^]

Also, if you'd actually tried "everything", then there wouldn't be anything left for us to suggest, so there would be no point in posting a question. :)

1 solution

Hi,
You are missing the most important feature of Bootstrap.
Bootstrap devide the screen verticaly into 12 sections. you have to group this sections depending on your need.
HTML
<div class="container">
  <div class="row">  
    <div class="col-sm-2">
<!-- 2 empty sections in the left -->
    </div>
    <div class="col-sm-8">
<!--Your form goes here -->
    </div> 
    <div class="col-sm-2">
<!-- 2 empty sections in the right -->
    </div>
  </div>
</div>

you can group sections however you like as long as the sum in the same row is 12.
Here is a fast&easy tutorial : Bootstrap 3 Tutorial[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900