I have tried to center this vertically in body
(not horizontally). Also, I do not want to specify heights or anything like that. I tried adding a wrapper with a 100% height and other things, but got nowhere. Can you please help me fix this?
<form name="signup" class="signup" action="signup.php" style="border: 1px solid #000; ">
<input type="text" placeholder="Email"/><br>
<input type="text" placeholder="Username"/><br>
<input type="password" placeholder="Password"/><br>
<button type="submit">Next</button>
</form>
Update: codepen.io
Related: Center a div in body
If you have flexbox available, you can do it without using
display: table;
Code example:
Ta-da! Vertically and horizontally centered content div. JSFiddle: https://jsfiddle.net/z0g0htm5/.
Taken mostly from https://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/ and https://css-tricks.com/snippets/css/a-guide-to-flexbox/
See this edited version of your jsFiddle.
Basically, just wrap your content in
<div class = "main"><div class = "wrapper"></div></div>
, and add the following CSS:A JSFiddle example with table warp
In the above solution, Provide css for html & body with
"height: 100%"
and then wrap the form that to be centered around a table.Code sample
this worked for me:
Style.css
I found this code snippet here.