How to set gravity of all content in a div to center?

Hi this is my js fiddle

I am trying to start all content from center but its not working.

Any help?

In this

I want all content to be start from center of div now it is starting from left

Wrap it in a div and apply the text-align: center.

It’s hackish, but this works (if I understand what you mean)

form {  text-align: center;}

It’s unclear what you want exactly as your question is a little ambiguous.

As others have said above you can centre the inputs and the button by simply applying text-align:center to the parent.



If you don’t want the text centred in the input then reset the text to left on the inputs.


#loginForm input{

If you are talking about vertical centering then that’s a more complicated scenario and will depend on a number of factors.

If you want all three items on one line but centred then remove the breaks you added.

It will help if you give as much information as possible when asking a question so we don’t have this guessing to and fro :slight_smile:



works for me


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.