Align Div in the midle of the screen [duplicate]


Align Div in the midle of the screen [duplicate]



This question already has an answer here:



Well I have my background (red border) and my login div (blue border)



I want to make my login div stay in the center of the screen. I'm using this code for this:



HTML CODE




</div>



CSS CODE


.login-background{
width: 100%;
height: 100%;
margin: 0;
padding: 30px;
position: fixed;
background: #eee;
overflow: hidden;
border: solid red;
}

.login{
margin: auto;
padding-bottom: 25px;
background-color: #dcf8c6;
boder: solid blue;
-webkit-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.54);
-moz-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.54);
box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.54);
}



But this isnt work for me. Look my screen:



enter image description here



How I can put this div in center (verticaly and horizontaly) on my screen?



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





Are you using Bootstrap 3 or 4? Flexbox makes this easy, so if flexbox is an option for you, this solution should work
– Jacob Stamm
Jun 29 at 18:28





@JacobStamm boostrap 3.3.7. But I think I can update if necessary
– Lucas Alves
Jun 29 at 18:32






With bootstrap 4, you only need to add the css class justify-content-center to the row, i.e., <div class="row background justify-content-center"> as grid system in bootstrap 4 uses flexbox. With bootstrap 3, you need center-block css class instead.
– David Liang
Jun 29 at 18:32



justify-content-center


<div class="row background justify-content-center">


center-block





this working for me @DavidLiang
– Lucas Alves
Jun 29 at 18:36




Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift