If you prefer not to use JS, there are alternative methods to create a modal effect. Here is another suggestion:
Check out this Bootly for a similar solution: http://www.bootply.com/SeRZCS7L09
You can achieve this using Twitter Bootstrap 3. By specifying the width in your own CSS and utilizing the grid system, you can easily create the desired layout. Refer to the bootstrap 3 documentation for more details.
If I were to implement this, I would follow these steps:
I would start with the HTML structure as follows:
<body>
<div id="login-form">
<h2>Login</h2>
<input type="text" class="form-control" name="password/>
<input type="text" class="form-control" name="username/>
</div>
</body>
Then, link my Bootstrap to benefit from form-control styles. Next, in my CSS stylesheet:
#login-form{
width: 400px;
margin:0 auto;
//add any other styles here
}
While this is a basic example, the Bootstrap documentation offers detailed guidance on using grids/columns/rows effectively. I highly recommend exploring it to achieve the desired look. I personally rely on Bootstrap for many projects.
For creating the darkened background, consider using a div with a black background and reduced opacity. You can make this element appear using transitions or JS. Check out CSS3 Opacity for more information: CSS3 Opacity