How to set a div in the center of the screen/parent div, and make it fixed, which will ignore the width changes after it has been placed in the center? I have a div which contain a table, it looks like this:
I am not sure whether the outer div is necessary or not. I want my table to be placed in center, and fixed, which it will ignore its width changes. Result below is what I get:
As you can see, the table moves left when its size changes to remain the table in center, I want to prevent this, any idea?
This is what I have so far:
.main
{
position: relative;
width: 600px;
left: calc(50% - 300px);
border: 1px solid #000;
}
.table
{
margin: 0 auto;
}
<div class="main">
<table class="table">
<tr><td>Username: </td><td><input type="text"></td><td>ErrorMessage</td></tr>
<tr><td>Password: </td><td><input type="text"></td><td>ErrorMessage</td></tr>
</table>
</div>